Ian Storm Taylor
Ian Storm Taylor

Reputation: 8690

Why can't I style the <html> element using attribute or class selectors in IE8?

See edit

I am setting a data-page attribute on my <html> tag to the id of the current page. So on my login page:

<html data-page="login">

For some reason, IE8 is not applying any styles like these:

[data-page="login"] { ... }
[data-page="login"] form { ... }
[data-page="login"] form input { ... }

Even though it is supposed to support the attribute selector. If I change the data-page to an id, and select it using #login, IE8 works fine.

Does anyone know how to fix this problem? I'd like to keep the attribute selectors.

EDIT: I've found that even trying to select with a class won't work, so it's not that. The problem seems to be that I cannot set styles on the <html> element at all in IE8.

Upvotes: 1

Views: 218

Answers (1)

Ian Storm Taylor
Ian Storm Taylor

Reputation: 8690

Ok, so I am a fool, but for anyone else who stumbles across this (as it is super mysterious until you realize it), I had forgot that I was using HTML5 Boilerplate-style conditional comments on the html element, so that the template variables were only being attached to the html element in non-IE browsers.

Upvotes: 3

Related Questions