Results 1 to 5 of 5

Thread: style type outside the head.

  1. #1
    Join Date
    Jan 2007
    Location
    Davenport, Iowa
    Posts
    2,385
    Thanks
    100
    Thanked 113 Times in 111 Posts

    Default style type outside the head.

    As I am making my site valid for html strict I notice that the <style type="text/css"> has to be within the head tag. Is there a way to have multiple head tags so that the <style type="text/css"> doesn't all have to be in the same location? It doesn't have to be multiple heads, but multiple style types located in places other than the top of the document.

    I understand this is convenient to have it all in one place, but there are occasions where I would like to submit a document to my database and have some extra css that applies only to that page. That way I don't create an ever larger css section that applies to all of the pages. Hope this makes sense.

  2. #2
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    To my understanding; in order to be valid HTML, it has to be in between the head tags; however, you could make several different stylesheets and link to the like so:

    Code:
    <link rel="stylesheet" href="main.css" type="text/css">
    <link rel="stylesheet" href="page-specific.css" type="text/css">
    That way you have a main stylesheet, plus for those pages you are wanting to add some page specific styling you have the page specific one as well.

    Hope this helps.
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

  3. #3
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    You'll have to modify your server-side scripts so that you can add things to the <head>.

    You can also make your stylesheet a PHP script.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  4. #4
    Join Date
    Jan 2007
    Location
    Davenport, Iowa
    Posts
    2,385
    Thanks
    100
    Thanked 113 Times in 111 Posts

    Default

    thetestingsite: As a way to organize my data that is a good idea, but it still seems like all of my pages will load all of the css scripts and become needlessly larger.

    Twey: I think I am sort of grasping what you are suggesting, but I am not sure what the program would look like. It sounds like you are talking about an include file that would only execute depending on the page accessed. If that is the case I will have to modify the php file every time I want to add a page that needs its own css include statement.

    Then again if I have a script that monitors the url to see if a piece of information is passed using the url, which would then include the css file if url value=yes. If url value=yes, then value2 will hold the name of the css file to include.

    That might work. complicated, but a good idea. Your mind is hard to read sometimes Twey

  5. #5
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Well here's how I do it:
    Code:
    $spechead = '';
    include(sprintf('includes/&#37;s.mod.php', $mod));
    require('template.php');
    And in template.php:
    Code:
    <?php echo($spechead); ?>
            </head>
    The module can then modify $spechead if it requires custom scripts or stylesheets in the head.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

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
  •