demosthenes.info

I’m Dudley Storey, the author of Pro CSS3 Animation. This is my blog, where I talk about web design and development with , and . To receive more information, including news, updates, and tips, you should follow me on Twitter.

featured articles

popular favourites

Pseudo-class selectors

Pseudo-class selectors define the appearance of an element in a particular state. Where appropriate, I have linked to examples in this blog. (Note: this entry is currently under revision).

CSS Pseudo-class selectors
Pseudo-class selector Purpose
:linkControls the appearance of an unvisited link. Strongly associated with the a tag, to the point at which the a selector used by itself before a style declaration accomplishes the same thing.
:visitedControls the appearance of visited links
:hoverControls the appearance of an element while it is being hovered over with a mouse or other pointing device. While it is heavily associated with the a tag (IE 6 & 7 only support a:hover) CSS does not explicitly specify this association. In modern browsers, :hover can be applied to any arbitrary element, such as img:hover.
:activeThe appearance of content while the user is clicking on it, i.e. between the mouse button being held down and it being released. Rarely used, since the effect is usually so transient.
:first-childSelects the first child element of a markup sequence. For example, ul li:first-child would specify that the style declaration applies to the first li element in any unordered list.
:last-childSelects the last child element in a sequence.
:nth-child(N)Selects the child in an element sequence iterations of (N), where N is the word odd, even, a number, or a mathematical expression.
:nth-of-type(N)
:focusSelects links that have been reached via keyboard navigation and form elements that are selected, such as text inputs and textareas.
:validThe state of a form element that is considered valid to a defined pattern of characters or numbers.
:invalidThe state of a form element with content that is considered invalid
:checkedSelects form elements that are checked, such as radio buttons or checkboxes.

Note that pseudo-selectors can be strung together: a:visited:hover, for example.

You must be signed up in order to leave comments.

"CSS3 has added a lot of pseudo-selectors. Some particularly useful ones are mentioned here, but are highlighted in red." It kind of sounds like the red items are not CSS3 commands as much as just your preferable selectors. May want to reword it =)

posted by Ian Carson

Dudley StoreyDone, Ian - I'll continue to modify the entry, which needs revision.

posted by Dudley Storey

web developer guide

featured comment

by Aisling Brock in New Business Card Design

what i'm reading

A Feast for Crows: A Song of Ice and Fire: Book Four
A Feast for Crows: A Song of Ice and Fire: Book Four

what i'm watching

Prometheus: Collector's Edition (Bilingual) [Blu-ray 3D + Blu-ray + DVD + Digital Copy]
Prometheus: Collector's Edition (Bilingual) [Blu-ray 3D + Blu-ray + DVD + Digital Copy]

what i'm playing

Borderlands
Borderlands

what i'm hearing

Planets
Planets

blogs

podcasts

no ads ever

This blog is free of advertising, and always will be.

creative commons licensed

The content of this blog is free to use in whatever way you wish under the Creative Commons license.