<style> tag inside any elements will still work?

Viewed 15366

I see something like this:

<div>
<style type="text/css">
...
</style>
</div>

It's very strange,but still work.

Is this against the standard?

5 Answers

In HTML5, a <style> tag is allowed to appear under anything in <body> or <head>.

Mostly you are not allowed to put blocking elements into inline elements but meta elements like style, script, meta may appear wherever you want.

I found an example where the tag inside a div is not read correctly by IE8 (it works fine in Firefox and Chrome) I can't reproduce it with a simple example because I don't know where the problem is. But if I move the outside the div everything works again. Why I'm using a tag inside a div? because I'm loading external data with AJAX inside that div, and I don't know other way to add the styles in that situation.

Related