For
example: h1.
Class .value Matches an element with a class value of
value.
ID #value Matches an element with an id value of
value.
Some selectors are not fully supported in all browsers. Notably, child and adjacent
selectors are not supported by versions of Internet Explorer prior to 7. See www.
webdevout.net/browser-support-css for an overview of basic selector support.
Selector type Syntax Description
Descendant element descendant Matches a descendant element that is a
descendant of the element of type element.
For example, div p targets paragraphs that
are descendants of div elements.
Child element>child Matches an element that is a child of another
element. Similar to but more precise than
descendant selectors, rules are applied to
elements that are direct children of the parent
only. For example, div p matches all
paragraphs within all divs. div>p only
matches paragraphs that are direct children
of divs, and so would not match a paragraph
within a table within a div.
Adjacent element1+element2 Matches element2, adjacent to element1. For
example, h1+h2 matches any h2 element that
directly follows an h1 element within the web
page, with no other elements in between.
Attribute element[attribute] Matches an element of type element that
has an attribute of type attribute. Further
clarification can be added via the syntax
element[attribute="value"] (targets
element with attribute with value equal to
value), element[attribute~="value"] (targets
element with attribute that has a list of
space-separated values, of which one is equal
to value), element[lang=value] (targets
element with a lang attribute equal to value).
Pages:
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577