Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2

Thread: A question

  1. #1
    New Coder
    Join Date
    Mar 2013
    Posts
    81
    Thanks
    45
    Thanked 0 Times in 0 Posts

    A question

    So I'm making a website and gonna use a same navigation bar,for instance i want nav and footer to stay there on all the pages, is it necessary to write header and footer code on all the pages?

  • #2
    Senior Coder
    Join Date
    Jan 2011
    Location
    Missouri
    Posts
    4,601
    Thanks
    24
    Thanked 647 Times in 646 Posts
    I use php to bring in these files. I make a header html doc with the doctype.. head and body tags(I use inline styling, but not necessary), then reduce it to something like this called header.html:
    Code:
    <div style="width:280px;margin:auto;">
    <h1>HELLO FOLKS!</h1>
    </div>
    Then give it a name and in the pages to come(they are php files) I put:
    PHP Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xml:lang="en" lang="en" xmlns="http://www.w3.org/1999/xhtml">
    <head></head>
    <body>
    <?php require ('header.html'); ?> 
    </body>
    </html>
    Same for the footer.

    If you don't care if the rest of the pages loads when there is a problem with the header or footer files, use 'include' instead of 'require' in the php call.
    Last edited by sunfighter; 04-07-2013 at 04:42 PM.
    Evolution - The non-random survival of random variants.

    "If you leave hydrogen alone, for long enough, it begins to think about itself."


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •