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

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

From: Keryx Web <webmaster@keryx.se>
Date: Fri, 18 Sep 2009 11:15:49 +0200
Message-ID: <4AB34FC5.9050706@keryx.se>
To: shirui@comsenz.com
CC: html-tidy <html-tidy@w3.org>
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)
Received on Friday, 18 September 2009 09:16:31 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 21:38:57 UTC