Re: how can I disable <style> element's movement?

2009-09-18 06:48, ʯÈð skrev:

> *How can I disable the style element's movement? Thanks a lot!*

You have already got an answer. Let me just elaborate on this issue.

When the browser parses the markup it will hoist the style-element to
the document head. Every single browser will put it there in its DOM.

Tidy just makes explicit what is already implicit, i.e. it makes your
code conform to the rules, so that the markup exactly matches the DOM.
That is a good thing.

There are two things you might be trying to achieve:

1. A local style, that really belongs in an attribute. Or better yet,
that you should reference with a selector, probably class- or id-.

2. A scoped style, which is a new concept in HTM5. Scoped styles will
not be hoisted to the head. But they are unsopprted in every browser
today, even Firefox 3.5, Opera 10, Safari 4 or Chrome 3. I.e. this
concept is not usable. When it becomes doable you stop the hoisting with
the attribute 'scoped="true"'.

Tidy is not HTML5 aware and will not honor such markup, though.

Scoped styles are not usable in real life projects for many years yet.

-- 
Keryx Web (Lars Gunther)
http://keryx.se/
http://twitter.com/itpastorn/
http://itpastorn.blogspot.com/

Received on Friday, 18 September 2009 09:16:31 UTC