CSS: Pseudo-Class Selectors

By Xah Lee. Date: .

These are misc CSS Pseudo Class selectors.

Match Links

a:link
Match a link.
a:visited
Match visited link.

Example, make link to have underline only when mouse hovers over it:

a:visited, a:link {text-decoration:none}
a:hover {text-decoration:underline;}

Match User Action

T:hover
mouse hover over a element T
T:active
Match a link that's clicked on but mouse button not yet released.
T:focus
when a element is in focus (receive keys, etc. Click on a element to put focus to it.)

Match Target

T:target
Match T that has a id value same as the current URL #fragment.

User Interface Pseudo-Class

T:enabled
Match a user interface T that is enabled.
T:disabled
Match a user interface T that is disabled
T:checked
Match a user interface T which is checked (example: radio-button, checkbox)
T:indeterminate
?

Match Language

T:lang(v)
Match T if its value of lang attribute is v.
Example: make Chinese paragraphs red.
p:lang(zh) {color:red;}

CSS Selectors (Syntax to Match HTML Elements)



CSS

Basics

Selectors

Color

Font

Text Decoration

Box Model

Box Decoration

Layout

Layers

Transform/Animation

Line Wrap

Misc