how to include html file in another html page

Discussion in 'HTML & Website Design' started by dineshsingh1984, Aug 1, 2012.

  1. #1
    how to include html file in another html page.
     
    dineshsingh1984, Aug 1, 2012 IP
  2. sarahk

    sarahk iTamer Staff

    Messages:
    28,839
    Likes Received:
    4,542
    Best Answers:
    123
    Trophy Points:
    665
    #2
    You can't - html is pretty "dumb" and just gives the browser some instructions to work with - which is why people use serverside scripting like PHP to create the html for a series of "parts". You'd be hard pressed to find a coder who doesn't work with php, asp, coldfusion, ruby or something similar.
     
    sarahk, Aug 1, 2012 IP
  3. Alejandro131

    Alejandro131 Greenhorn

    Messages:
    24
    Likes Received:
    0
    Best Answers:
    3
    Trophy Points:
    21
    #3
    Actually what I think he meant was how to get a page to get displayed in another page. It's pretty simple - using a frame or Iframe as they call them now (you can google it and find some nice articles and tutorials about it).

    Basically you put something along the lines
    
    <iframe src="coolPage.html" width="200" height="200"></iframe>
    
    Code (markup):
    in your html file, where you can set the src to the html document you want and you can control the width and height of the displayed page to whatever you want.
    Normally I would advise against using frames as it is quite an old standard (though it doesn't stop facebook applications to use it as a way to display content) and now people can do whatnot with CSS and some JavaScript, but if you want to display the contents of one page inside another I can't think up of something better than a frame.
     
    Alejandro131, Aug 1, 2012 IP
  4. Cydefense

    Cydefense Peon

    Messages:
    17
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    1
    #4
    You can use <iframe></iframe> to include html file in an another html page.
     
    Cydefense, Aug 1, 2012 IP
  5. kind_of_the_cash

    kind_of_the_cash Active Member

    Messages:
    852
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    85
    #5
    kind_of_the_cash, Aug 1, 2012 IP
  6. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,999
    Best Answers:
    253
    Trophy Points:
    515
    #6
    NOT that anyone has ANY business using IFRAME's after 1998... It's been deprecated for a REASON. OBJECT would be the correct tag, but that too has accessibility issues for most instances.

    Really though we need more details for a proper answer -- are you talking about literally embedding one page inside another, or are you talking about piecing together bits to reduce code and simplify maintenance/updates -- if the latter, you want SHTML, PHP, ASP or some other form of server-side-includes.
     
    deathshadow, Aug 1, 2012 IP
  7. cesurasean

    cesurasean Active Member

    Messages:
    269
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    80
    #7
    Keep in mind that browsers other than IE have a hard time rendering iframes. It's best to merge everything into 1 html document.
     
    cesurasean, Aug 1, 2012 IP
  8. setyp

    setyp Member

    Messages:
    25
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    38
    #8
    also you can use javascript to include other page.
     
    setyp, Aug 6, 2012 IP
  9. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,999
    Best Answers:
    253
    Trophy Points:
    515
    #9
    Uhm... since when?
     
    deathshadow, Aug 6, 2012 IP