Search code examples
cssxhtmlclearfix

Is there a non-trivial purpose for defining a css style for HTML[xmlns]?


Note this clearfix solution offered here.

Why is there a separate style defined for HTML[xmlns]?

Is this a CSS hack designed to target a specific browser?

UPDATE: Here is the code in question, since some of the answers are obviously way off the mark in my opinion.

.clearfix {
    display: inline-block;
}

html[xmlns] .clearfix {
    display: block;
}

* html .clearfix {
    height: 1%;
}

UPDATE 2: It's already more-or-less established that it's a hack. But I want an external reference that explains it in detail. e.g., which browser does it apply to, and exactly what problem does it purport to fix?


Solution

  • I contacted Stu Nicholls to try to track down a definitive source on this hack. He replied and gave me the following information:

    element[attribute] is a w3.org CSS2 Attribute Selector which is normally applied to body elements and attributes but in this case it uses the tag and its ‘xmlns’ attribute. So [you know it] is to isolate browsers which will either recognise or ignore this style. The answer is that ALL browsers will recognise this style EXCEPT IE5.x and IE6. So all browsers will style the .clearfix as an inline-block, then all but IE5.x and IE6 will restyle this as a block.
    Then using the * html prefix to target IE5.x and IE6 ONLY the height of the .clearfix element is set to 1%.