Hello and welcome to our community! Is this your first visit?
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
    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. #2
    Master Coder sunfighter's Avatar
    Join Date
    Jan 2011
    Thanked 1,012 Times in 1,009 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:
    <div style="width:280px;margin:auto;">
    <h1>HELLO FOLKS!</h1>
    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">
    <?php require ('header.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.
    Physics is actually atoms trying to understand themselves.


Posting Permissions

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