Applies to any element whose class attribute value is equal to className.
<head><style>.myClass {
color:red;
}
</style></head><body><bclass="myClass">This bold tag color is red.</b><divclass="myClass">This division is red, too.</div><b>But this bold tag is black.</b></body>
Applies to an element of type E whose class attribute value is equal to className.
<head><style>B.myClass {
color:red;
}
</style></head><body><bclass="myClass">This bold tag color is red.</b><divclass="myClass">This division is black.</div><b>And this bold tag is black, too.</b></body>
Applies to an element of type E whose id attribute value is equal to myID.
<head><style>B#myBold {
color:red;
}
</style></head><body><bid="myBold">This bold tag color is red.</b><divid="myBold">This division is black.</div><b>And this bold tag is black, too.</b></body>
Applies to an element of type E with an "attr" attribute.
Note, this property works in Internet Explorer only from version 7.
<head><style>span[title] {
color:red;
}
</style></head><body><spantitle="red text">span with title attribute</span><br/><span>span without title attribute</span></body>
Applies to an element of type E with an "attr" attribute and whose value contains at least one occurance of the "val" string.
Note, this property works in Internet Explorer only from version 7.
<head><style>span[title*="hello"] {
color:red;
}
</style></head><body><spantitle="hello my friend">span with "hello" in title</span><br/><spantitle="my friend">span without "hello" in title</span></body>
Applies to an element of type E whose "attr" attribute value is a list of space-separated values, and at least one is equal to "val".
Note, this property works in Internet Explorer only from version 7.
<head><style>span[title~="hello"] {
color:red;
}
</style></head><body><spantitle="hello my friend">span with "hello" in title</span><br/><spantitle="hello-my-friend">span with "hello" in title, but separated with hyphen</span></body>
Applies to an element of type E whose "attr" attribute value is a list of hyphen-separated values, and at least one is equal to "val".
Note, this property works in Internet Explorer only from version 7.
<head><style>span[title|="hello"] {
color:red;
}
</style></head><body><spantitle="hello-my-friend">span with "hello" in title separated with hyphen</span><br/><spantitle="hello my friend">span with "hello" in title, but separated with space</span></body>
Applies to an element of type E with an "attr" attribute and whose value begins exactly with "val".
Note, this property works in Internet Explorer only from version 7.
<head><style>span[title^="hello"] {
color:red;
}
</style></head><body><spantitle="hello my friend">span with "hello" at the beginning in title</span><br/><spantitle="my friend hello ">span with "hello" at the end in title</span></body>
Applies to an element of type E with an "attr" attribute and whose value ends exactly with "val".
Note, this property works in Internet Explorer only from version 7.
<head><style>span[title$="hello"] {
color:red;
}
</style></head><body><spantitle="hello my friend">span with "hello" at the beginning in title</span><br/><spantitle="my friend hello">span with "hello" at the end in title</span></body>
Applies to an F element that is a descendant of an E element.
<head><style>BSPAN {
color:red;
}
</style></head><body><span>a stand alone span</span><br/><b><span>span within a b element</span></b><br/><b><i><span>span within a b element but not as a direct child</span></i></b></body>
Applies to an F element that is a direct child of an E element.
Note, this property works in Internet Explorer only from version 7.
<head><style>B > SPAN {
color:red;
}
</style></head><body><span>a stand alone span</span><br/><b><span>span within a b element</span></b><br/><b><i><span>span within a b element but not as a direct child</span></i></b></body>
Applies to an F element that is immediately preceded by an E element.
Note, this property works in Internet Explorer only from version 7.
<head><style>B + DIV {
color:red;
}
</style></head><body><div>a div element</div><b>this is a bold element</b><div>a div element preceded by a bold element</div><div>another div element </div></body>
Applies to an F element that is preceded by an E element.
Note, this property works in Internet Explorer only from version 7.
<head><style>B ~ DIV {
color:red;
}
</style></head><body><div>a div element</div><b>this is a bold element</b><div>a div element preceded by a bold element</div><div>another div element </div></body>