Prev | Current Page 119 | Next

Tommy Olsson and Paul O'Brien

"The Ultimate CSS Reference"


element and descendant element, have
a look at CSS Layout and Formatting (p. 139) for a complete explanation.
The combinator we use in a descendant selector is a whitespace character: a space,
horizontal tab, carriage return, line feed, or form feed. Since whitespace characters
are allowed around all combinators, you can include more than one whitespace
character between the simple selectors in a descendant selector.
Consider the following HTML fragment:

  • Item 1



    1. Sub-item 2A

    2. Sub-item 2B




We??™ll try to match elements in the above fragment using the selector below:
75 Selector Reference
ul li {
?‹® declarations
}
This descendant selector will match all four li elements in the example HTML,
because each of those elements has a ul element as its ancestor.
We can also use descendant selectors to match the li elements within the ol in the
example above:
ul * li {
?‹® declarations
}
ul * * li {
?‹® declarations
}
ul * ol li {
?‹® declarations
}
ul li * li {
?‹® declarations
}
ul ol li {
?‹® declarations
}
ul li li {
?‹® declarations
}
ul li ol li {
?‹® declarations
}
However, there??™s no way we can use descendant selectors to match only the list
items in the unordered list.


Pages:
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131