2

I have in my file "abc.css":

* +html .news .image{ .... }

What does this do? Any ideas?

4
  • 3
    They're selectors. Start reading: w3.org/TR/CSS21/selector.html
    – Marc B
    Commented Dec 1, 2014 at 21:32
  • @MarcB What's the point of using the adjacent selector after the * wildcard though? Wouldn't this achieve the same as html .news .image{}? Commented Dec 1, 2014 at 21:33
  • what'd be the point of selecting <html> explicitly since it's a top level singleton element anyways? It's probably some hacked up CSS to work around IE bugs, since IE for some reason has an invisible/unamed element that exists above body/html that * html would select.
    – Marc B
    Commented Dec 1, 2014 at 21:34
  • * + html describes impossible situation, because html node cannot have siblings, since it's a root element in the tree. So this selector makes no sense. All browsers understand it and simply ignore such a weird selector. All but IE7, which due to some bug in parser implementation applies the rule .news .image { .... }.
    – dfsq
    Commented Dec 1, 2014 at 21:39

1 Answer 1

3

According to Wikipedia the *+html part is an IE7 "star plus" specific hack, which is based on an earlier "star" hack. For example:

*+html p { font-size: 5em; }

This code will be applied in Internet Explorer 7, but not in any other browser. Note that this hack only works in IE7 standards mode; it does not work in quirks mode. This hack is also supported by Internet Explorer 8's compatibility view (IE7 standards mode), but not in IE8 standards mode. Like the star HTML hack, this uses valid CSS

As Marc B mentioned in the comments, it's an IE hack that works because of a mysterious parent element that IE used to employ:

The html element is the root element of the W3C standard DOM, but Internet Explorer versions 4 through 6 include a mysterious parent element.[8] Fully compliant browsers will ignore the * html selector, while IE4-6 will process it normally. This enables rules to be specified for these versions of Internet Explorer which will be ignored by all other browsers. For example, this rule specifies text size in Internet Explorer 4-6, but not in any other browsers.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.