Friday, August 29, 2008

Adjacent Sibling Selector

The meaning of sibling in general language is brother or sister. In (X)HTML it means any elements that are in the same level in the document tree. In other words, sibling elements are those that have a common parent; they are contained in the same element. Adjacent sibling elements are those that are next to each other and are contained in the same element.
An adjacent sibling selector selects a sibling element that comes immediately after a particular element. The combinator of the adjacent sibling selector is the plus sign + . Remember, the element that is first in the (X)HTML document must also appear first in the selector.
Example: h1 + p {background-color:green;}
Note: The Adjacent Sibling selector is not supported by IE6 (it is ignored).

No comments: