Off page CSS Nav bar

Discussion in 'CSS' started by heyman12, Sep 22, 2008.

  1. #1
    I've worked with HTML for about a year now, and finally getting around to learn CSS. My question is, can I build a nav bar that will appear on every page using CSS?

    I have rollover CSS links, but I still have to copy those on each page. I hope to have a block of static code on my HTML docs that will load the nav bar from an off document source, such as my CSS styles sheet.

    Does anyone know how to do this?
     
    heyman12, Sep 22, 2008 IP
  2. skateme

    skateme Peon

    Messages:
    162
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #2
    This is not possible using CSS but you can do this with server side includes. In PHP it will be:

    
    <?php include("nav.inc"); ?>
    
    Code (markup):
    In HTML it will be:

    
    <!--#include file="nav.txt" -->
    
    Code (markup):
    Keep in mind that the page utilizing the include must end in .php if the include is in PHP or .shtml if the include is in HTML.
     
    skateme, Sep 22, 2008 IP
  3. le007

    le007 Well-Known Member

    Messages:
    481
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    103
    #3
    skateme just gave you the perfect answer. Personally, I'd design every page with a .php extension and try and learn a little more about php as you go.

    The include command can be used in many ways - you can minimise your work so much - include headers, menus, content - and when you get a lot of html, css and php knowledge - throw it all together you'll be able to include configurations such as cookies, logins, database connections.

    Basically - use this php include line - its handy and is the modern day version of html frames (in a way).
     
    le007, Sep 22, 2008 IP
  4. DesignSamples

    DesignSamples Banned

    Messages:
    170
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #4
    le007 - I couldn't have said that better myself!! - lol @ modern day frames...!
     
    DesignSamples, Sep 22, 2008 IP
  5. heyman12

    heyman12 Peon

    Messages:
    56
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Thanks for the info, works great! I'm glad to be learning PHP as well.
     
    heyman12, Sep 23, 2008 IP