Monday, April 25, 2011

Website Header in HTML

How do I create a webpage with a header, content, and a footer. I am using TextEdit on my Mac and saving the file with a .HTML extension.

From stackoverflow
  • I assume you have some ability to run a scripting language on your host, so just write a header and footer file, and include those in your content page with your dynamic language of choice.

  • You can go through the 3+3 tutorials for HTML and CSS on HTML Dog.

    Sunny : RTFM is hardly a good answer.
    cherouvim : @Sunny: The question was very basic and my answer did not have any RTFM tone in it :)
    Sunny : Undoing the downvote, as the OP accepts this, but still its better to provide a solution :)
    cherouvim : @Sunny: Thanks. I still think that in this case the solution is to point the author to the tutorial itself instead of trying to guess what he means or copy pasting huge tutorial sections in here.
  • create an html file paste this frames :

    <html>
    
    <frameset rows="25%,50%,25%">
    
      <frame src="header.htm">
      <frame src="content.htm">
      <frame src="footer.htm">
    
    </frameset>
    
    </html>
    

    and then create your header, content and footer files in same directory.

    Chris Ballance : Ugh, Frames?!? Blasphemy
    Rex M : Sweet god almighty, I thought we eradicated this like Polio!
    cherouvim : Yes, frames suck but it's the only way to do modularization in a static html environment. So ++
    Rex M : No one is asking about file modularization. So this is heaping bad upon bad.
    cherouvim : @Rex M: The question was very vague and it was not clear what the intention was.
    Canavar : @Rex M : strange people, he is not asking about file modularization, ok, but not asking for one and only one file.. it's an answer, and not wrong, like or dislike..
  • <html>
    <head><title>my title</title></head>
    
    <h1>My Header</h1>
    
    <p>The quick brown fox jumps over the lazy dog.</p>
    
    <h4>My footer</h4>
    </html>
    

    my title

    My Header

    The quick brown fox jumps over the lazy dog.

    My footer


    Optionally, you can put each section in a separate file, or specifically the header and footer in separate files to be reused.

  • If your web server is Apache (I would guess on Mac), you can use server-side includes:

    <html>
    .....
    <body>
    <!--#include virtual="myheader.html" --> 
    
    YOUR CONTENT GOES HERE
    
    <!--#include virtual="myfooter.html" --> 
    </body>
    

0 comments:

Post a Comment

Note: Only a member of this blog may post a comment.