Dynamic HTML: The Definitive Reference

4.2. Selectors

Most style sheet rules are associated with distinct HTML elements or groups of elements identified via style sheet selectors, such as classes, IDs, and contextual selectors (see Chapter 3). Table 4-1 lists these selectors as defined in W3C recommendations through CSS3, along with mainstream browser version support. In the Format column, E and F stand for element (i.e., tag) names of two different elements. As shown in Appendix F, the "m18" designation in the Mozilla column indicates an early milestone release number.

Table 4-1. Primary CSS selectors

Name

Format

IE

Mozilla

Safari

Opera

CSS

Adjacent sibling

E + F

7

m18

all

7

2

Attribute (name)

E[attr]

7

m18

all

7

2

Attribute (name and value)

E[attr="val"]

7

m18

all

7

2

Attribute (name and any value)

E[attr~="val"]

7

m18

all

7

2

Attribute (name and any value up to hyphen)

E[attr|="val"]

7

m18

all

7

2

Attribute (name and value start)

E[attr^="val"]

7

1.0.1

all

9

3

Attribute (name and value end)

E[attr$="val"]

7

1.0.1

all

9

3

Attribute (name and value contains)

E[attr*="val"]

7

1.0.1

all

9

3

Child

E > F

7

m18

all

7

2

Class

E.classname

4

m18

all

7

1

Descendant

E F

4

m18

all

7

1

General sibling

E ~ F

7

1.7.2

n/a

9

3

ID

E#id

4

m18

all

7

1

Type

E

4

m18

all

7

1

Universal

*

4

m18

all

7

2

Категории