View Full Version : style type outside the head.
james438
08-26-2007, 08:30 PM
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.
thetestingsite
08-26-2007, 08:48 PM
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:
<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.
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.
james438
08-26-2007, 09:28 PM
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 :cool:
Well here's how I do it:
$spechead = '';
include(sprintf('includes/%s.mod.php', $mod));
require('template.php');And in template.php:
<?php echo($spechead); ?>
</head>The module can then modify $spechead if it requires custom scripts or stylesheets in the head.
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.