HTML and CSS Reference
In-Depth Information
In the first example, the universal asterisk selector applies the style to
all elements of your document so that any text gets displayed in Zapf
Dingbat characters. [*] The second example selects a particular child/
parent relationship; in this case, items in an ordered list. The third ex-
ample illustrates the adjacent selector type, which selects for one tag
immediately following another in your document. In this case, the spe-
cial selector adds vertical space to instances in which your document
has a level-2 header immediately following a level-1 header.
[*] Assuming, of course, that the style is not overridden by a subsequent rule.
8.2.5. Attribute Selectors
It is possible to attach a style to only those HTML/XHTML elements that
have specific attributes. You do this by listing the desired attributes in
square brackets ( [] ) next to the element name, before the style defini-
div[align] { font-style: italic }
div[align=left] {font-style: italic }
div[title~="bibliography"] { font-size: smaller }
div[lang|="en"] {color: green }
The first example is the simplest: it italicizes the subsequent text con-
tents of only those <div> tags that contain the align attribute, regardless
of the value assigned to the attribute. The second example is a bit pick-
ier; it matches only <div> tags whose align attributes are set to left .
The third example matches any <div> tag whose title attribute contains
the word bibliography , specifically delimited by one or more spaces. Par-
tial word matches do not count; if you used div[title~="a"] , you would
match only <div> tags whose title attributes contained a single "a" de-
limited by spaces (or at the beginning or end of the title).
Search WWH ::

Custom Search