Forum Moderators: open

Message Too Old, No Replies

Warning: <style> isn't allowed in <div> element

I got this from an html validator

         

pixeltierra

1:03 am on Feb 11, 2007 (gmt 0)

10+ Year Member



Ok, call me stupid, but I've been doing this for a long time.

I use scripting to bring in header and footer files.

I keep page-specific styles on the page in <style></style>, instead of the master css file, to keep it free of clutter.

However, my docs are structured this way:

<include header>

<style>
</style>

<content>

</content>

<include footer>

Since in the header divs are started like this:
<div id="container">
<div id="content">

And in the footer divs are ended like this:

</div><!-- end content -->
</div><!-- end container-->

My page-specific styles always occur inside divs. What do I do?

Should I pay this warning any mind (Warning: <style> isn't allowed in <div> element)? Or should I keep doing what I've been doing.

encyclo

3:24 am on Feb 11, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yes, you should pay attention to the warning. Although browsers mostly handle style blocks outside the
head
section, it may confuse spiders into thinking the following content is within the
head
rather than the body, which would have a negative influence on the page's spiderability.

You should define your page styles as variables before including the header, then within the header include you can echo the page styles in the appropriate place.

pixeltierra

7:53 am on Feb 11, 2007 (gmt 0)

10+ Year Member



What a drag!

I use gvim (editor) and all my pretty highlighting goes away when you make the styles variables.

I don't seem to get an error when I use <script></script> between <divs>. If I can use that, I don't understand why <style></style> is any different.

I can't, however think of any other option, short of splitting up my header include.

kaled

11:49 am on Feb 11, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Logically, <style> should be permissiable within any block element, unfortunately, like other simple and obvious features, it is missing from HTML 4 and, so far as I am aware, is not likely to appear in any future versions either - crazy.

Kaled.