HTML and CSS Reference
In-Depth Information
Targeting with Selectors
The rules that browsers use to parse CSS selectors dictate that unknown
syntaxes for selectors should cause the entire rule to be ignored. You can
use that, combined with recent selectors that were not implemented in
older browsers, to carefully craft rules for browsers. This can be one of the
cleanest ways to target different features toward different editions of
browsers or to offer fallback options for older browsers. You could write
the following two CSS declarations:
html body { background-color: red; }
html>body { background-color: blue; }
Browsers that support the child selector will display a red background on
the page, and those that do will display in blue.
Targeting with Syntax Hacks
Some browsers don't quite follow the same parsing rules and handle
what would be considered an error or invalid syntax in a unique manner.
Over time, web developers have stumbled upon (or gone on quests
to find) these differences and used them as “hacks” in some form of
browser targeting.
In the following example, most browsers will ignore the unknown prop-
erty _height , but IE will instead ignore the _ character and consider it as
a “height,” giving you a way to send a different value to IE if needed.
div {
height: 200px;
_height: 300px;
Search WWH ::

Custom Search