Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

bye-bye holly hack...

7 views
Skip to first unread message

VK

unread,
Nov 15, 2006, 9:01:58 AM11/15/06
to
That happened: Microsoft acknowledged the fact that HTML element is
the topmost one in any HTML document and that there is nothing atop of
it (DOCTYPE declarations and prologs are not normally styled by
stylesheet means :-)

Not only the fact acknowledged by also the relevant bug fixed in IE7.
It means that it's time to say bye-bye to the infamous "holly hack":
sooner is better. Actually Microsoft gave a generous share of time for
updates (announcing the planned bag fixes since the 2005) : but there
will be always someone left behind.

This way if you have in your stylesheet the rule * html (universal
selector - html) and if it supposes to mean "further rules for that
stupid IE only" then your stylesheet is rather badly broken for an
increasing amount of your visitors.

Which ones of existing workarounds are still needed for all versions of
IE (including IE7) is a subject of separate tests.

I'd just like to explain how to use these workarounds in a reliable and
*working* way.

1) Conditional comments (IE 5.0 or higher for all platforms)

1-1) Conditional content-hiding comments
These comments are using the regular comment syntax, so any UA's except
IE will simply not see anything inside of them. Respectively W3C
Validator doesn't care neither.

1-1-1) No version check. Will be seen and parsed by IE 5.0 or higher.
Other words by any IE version with conditional comments support.
<!--[if IE]>
<link rel="stylesheet" href="ie_fix.css">
<![endif]-->

1-1-2) Version check using operators lt (lesser than), lte (lesser than
or equals to), gt (greater than), gte (greater than or equals to)
<!--[if lt IE 6]>
Will be seen and parsed by IE 5.0 - IE 5.5
<![endif]-->

<!--[if gte IE 7]>
Will be seen and parsed by IE 7.0 or higher
<![endif]-->

1-2) Conditional content-revealing comments.
These blocks will be seen by all browsers but we can instruct IE do not
parse them. Unfortunately this syntax makes W3C Validator all upset
(UA's themselves do not care). This way content-revealing comments
cannot be advised for W3C-validating pages.
<![if !IE]>
Will be seen and parsed only by non-IE browsers
<![endif]>

2) Disabled styleshets.
<link rel="stylesheet" href="not_for_.css" disabled="true">
IE will not apply this stylesheet because of disabled attribute. Other
UA's (AFAIK) do not support neither understand neither planning to
implement this attribute.

3) Expression override
This can be used for small fixes inside the stylesheet itself:
#MyContainer {
/* for all: */
width: 200px;
/* for IE only: */
width: expression("200px");
}

P.S. It doesn't elimitate the possibility to find another bug in IE7 to
use it as a holly hack replacement. (Why?) For researches one can study
all selectors supported by IE7:
<http://msdn.microsoft.com/workshop/author/css/reference/css_ref_entry.asp>

Johannes Koch

unread,
Nov 15, 2006, 9:22:36 AM11/15/06
to
VK schrieb:

> That happened: Microsoft acknowledged the fact that HTML element is
> the topmost one in any HTML document and that there is nothing atop of
> it (DOCTYPE declarations and prologs are not normally styled by
> stylesheet means :-)

'* html' means 'html elements which have an ancestor element'.

1. A DOCTYPE declaration is no element.
2. A DOCTYPE declaration is not an ancestor, but a sibling node of the
root (html) element (in DOM terms).
--
Johannes Koch
In te domine speravi; non confundar in aeternum.
(Te Deum, 4th cent.)

dorayme

unread,
Nov 15, 2006, 9:25:46 PM11/15/06
to
In article
<1163599318.7...@i42g2000cwa.googlegroups.com>,
"VK" <school...@yahoo.com> wrote:

> It means that it's time to say bye-bye to the infamous "holly hack":
> sooner is better.

This "sooner is better" remark seems to me to indicate a
prejudice. Is it not the case that at least the * html hack is
simply ignored by most other browsers. So what is so terrible
about it?

I reckon some people have too rigid an eye for beauty. A face can
be the more interesting, even beautiful, for a slight blemish. So
too can a css sheet or html doc. I have weeped at the sight of
some of these hacks, my knees have gone all wobbly, the trembling
always starts at the first sight of the * html and the \ (this
latter is exquisite indeed)

--
dorayme

Eric B. Bednarz

unread,
Nov 15, 2006, 10:26:52 PM11/15/06
to
"VK" <school...@yahoo.com> writes:

> That happened: Microsoft acknowledged the fact that HTML element is
> the topmost one in any HTML document and that there is nothing atop of

^^^^^^^
> it

window.alert(document.documentElement.parentNode.nodeName);

(NB, this is ‘The root of the document tree’ in CSS 2 9.1.2)

> (DOCTYPE declarations and prologs

A document type declaration is *part* of the prolog (both in SGML and
XML).

> are not normally styled by
> stylesheet means :-)

SGML/XML declarations, document type declarations, PIs, comment
declarations and whitespace preceding the root element are its siblings
anyway, not its parents.

> This way if you have in your stylesheet the rule * html (universal
> selector - html) and if it supposes to mean "further rules for that
> stupid IE only" then your stylesheet is rather badly broken for an
> increasing amount of your visitors.

Only for developers who didn’t read the M$ documentation and delivered
“content that is [not] fixed in nature”.

<http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnie60/html/cssenhancements.asp>
=> “The Way It Was”

* html *

still works in IE7 in BackCompat mode.


--
||| hexadecimal EBB
o-o decimal 3771
--oOo--( )--oOo-- octal 7273
205 goodbye binary 111010111011

VK

unread,
Nov 16, 2006, 7:08:03 AM11/16/06
to
> > are not normally styled by
> > stylesheet means :-)
>
> SGML/XML declarations, document type declarations, PIs, comment
> declarations and whitespace preceding the root element are its siblings
> anyway, not its parents.

That sentence in parenthesis was a humoristic (see the smily)
suggestion of how that erroneus * element atop of html could ever
appear in IE on the first place. But thanks for everyone commenting on
the prolog nature: it is useful for everyone else reading this thread.

> * html *
> still works in IE7 in BackCompat mode.

Unless it was pseudo-XHTML with <xml> starting the prolog. In IE before
7 it forced BackCompat on IE even with doctype presented.

But I'm a bit lost now: was * atop of html a bug or not? If it was then
what reason would be to keep using broken stylesheets (containing
illegal ruleset declarations) when there are descent "bug fix
independent" tools to achieve the same goal?

Johannes Koch

unread,
Nov 16, 2006, 7:31:31 AM11/16/06
to
VK schrieb:

> But I'm a bit lost now: was * atop of html a bug or not?

It's not an error wrt CSS. It's just a selector that selects an element
not existing in HTML documents.

Michael Winter

unread,
Nov 16, 2006, 11:15:08 AM11/16/06
to
Eric B. Bednarz wrote:

> "VK" <school...@yahoo.com> writes:
>
>> That happened: Microsoft acknowledged the fact that HTML element is
>> the topmost one in any HTML document and that there is nothing

> ^^^^^^^
>> atop of it


>
> window.alert(document.documentElement.parentNode.nodeName);
>
> (NB, this is ‘The root of the document tree’ in CSS 2 9.1.2)

As far as I can see, there is a difference between the DOM and CSS
Recommendations regarding what constitutes the "root of the document
tree". The DOM Core Recommendation describes it unequivocally as the
Document interface:

The Document interface represents the entire HTML or XML
document. Conceptually, it is the root [p.99] of the document
tree, and provides the primary access to the document’s data.

The DOM defines the document tree in terms of nodes and the root element
cannot be the root node: it has siblings. However, the CSS
Recommendation describes the document tree in terms of elements:

Document tree
The tree of elements encoded in the source document. Each
element in this tree has exactly one parent, with the
exception of the *root* element, which has none.

(the word "root" has strong emphasis in the document, and is considered
a definition). Therefore, one can conclude that when the Recommendation
states:

The root of the document tree [p. 30] generates a box that serves as
the initial containing block for subsequent layout.

in section 9.1.2 Containing blocks, it is referring to the root element.
In HTML documents, the html element is that root and serves as the
initial containing block.

* html

is nonsense (however useful it might be).

[snip]

Mike

Eric B. Bednarz

unread,
Nov 16, 2006, 12:45:33 PM11/16/06
to
Michael Winter <m.wi...@blueyonder.co.uk> writes:

> As far as I can see, there is a difference between the DOM and CSS
> Recommendations regarding what constitutes the "root of the document
> tree".

The whole issue has vanished from the 2.1 draft anyway, not without a
reason. Just for the fun of it:

<http://lists.w3.org/Archives/Public/www-style/2001Jul/0038.html>

IMO that makes perfect sense of seemingly contradicting definitions in
CSS 2.

But as there is no official clarification that I am aware of, I should
probably have written ‘probably’. ;)

> * html
>
> is nonsense (however useful it might be).

I did not intend to imply anything else.

0 new messages