Rob Desbois wrote:
Just to extend on what Su said - you would never need a class or even ID for the <html> tag because there *is* only one (or should be anyway!)
So, to target it with a CSS rule you just need:
   html { /* ... */ }

But as he says, why would you need to target <html> not <body>?
Rob.

Even with a DOM ready event by attaching a flag to the HTML element it is a faster way to apply degradable JS related styles to elements.

Take the tabs for example: Depending on what else is going on you may notice a minimal flash of content there before they're initialized. Thus there is the wish to have the content hidden until initialization is done. But simply hiding relevant containers via CSS wouldn't degrade gracefully in the JS off/CSS on scenario. The elements would be inaccessible.

You could juse document.write a special JS related style sheet into the head, but with that I encountered some timing issues in Safari for example.

There are solutions out there that attach a class like "js" to the body, but that involves adding a script element after the opening body tag. Ugly.

Using the HTML element is better because it is also faster, you can attach the flag immediatly before any other style sheet or javascript has been loaded.

Cool, I did not do it because of the invalid class element on the the html element, but never thought of the id...


-- Klaus

Reply via email to