SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    Sep 2001
    Posts
    84
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    possible to have text written in css file sort of like a 'header.txt' file?

    don't know if this is possible and haven't found anything that helps in any of my failed searches on css sites, but you know how you can include a header.txt file on pages? is this possible using css? so the 'this is the header for each page' goes in the .css file and the text is shown on every page?

  2. #2
    SitePoint Addict xDev's Avatar
    Join Date
    Jul 2003
    Location
    Moncton, New Brunswick, Canada
    Posts
    247
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    That's not the purpose of css, and no, it's not possible. CSS is a way to seperate the style from the markup of your page. You can "include" a css file on every page easy enough, but it doesn't write out your header. It will style parts of the include fine

    What your looking for is a server-side solution that will insert the include header on every page before the contents are sent to the browser. PHP does this very easily with a simple function:

    PHP Code:
    include("header.htm"); 
    The header file can look something like this:
    HTML Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>Same Header for every page!</title>
    <link rel="stylesheet" type="text/css" 
    href="css/myStyle.css" />
    </head>
    
    <body>
    <div id="mymenu">etc...</div>
    yada yada ..
    Or anything you wish. So your php page would look like this under the hood:
    PHP Code:
    <?php
    include("header.htm");
    ?>
    <p>
     Contents of your page
    </p>

    rest of page etc...
    <?php
    include("footer.htm");
    ?>
    Reference from the php manual:
    http://ca3.php.net/manual/en/function.include.php


    -xDev

  3. #3
    SitePoint Enthusiast
    Join Date
    Sep 2001
    Posts
    84
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks! i've seen a couple things (like replacing images with text) that made me wonder if it was possible using some kind of visible tag. just a thought.


Bookmarks

Posting Permissions

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