W3C home > Mailing lists > Public > html-tidy@w3.org > July to September 2009

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

From: 石瑞 <shirui@comsenz.com>
Date: Fri, 18 Sep 2009 17:29:59 +0800
To: "Keryx Web" <webmaster@keryx.se>
Cc: "html-tidy" <html-tidy@w3.org>
Message-ID: <200909181729591383698@comsenz.com>
Keryx Web, thank you very much.

I have solved my problem through your first method, its really a clever way. Thanks a lot!






发件人: Keryx Web 
发送时间: 2009-09-18  17:15:55 
收件人: shirui 
抄送: html-tidy 
主题: 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:32:36 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 3 April 2012 06:13:59 GMT