-->

Cascading Style Sheets

skip to content


Pseudo Classes

a:link

Specifies the style rule for unvisited links.

a:active

Specifies the style rules for active (currently selected) links.

a:visited

Specifies the style rules for visited links.

:hover

Specifies the style rules for elements that a mouse pointer is currently pointing to. It is the equivalent of the onMouseOver attribute for use with JavaScript.

:focus

Specifies the style rules for elements that have been selected with the keyboard, or for elements that have been selected to accept keyboard input.

:first-letter

Allows you to apply special formatting to the first letter of an element.

:first-line

Allows you to apply special formatting to the first line of an element. Normally only used with paragraphs.

:first-child

Allows you to apply special formatting to an element if it is the first child of another element. If you want to specify first child of what, then you need to use contextual selectors, such as div > p:first-child. We talk about contextual selectors elsewhere.

:before

This selector allows you to add CSS generated content to the beginning of an element. It can be used for such things as prefixing a selection with a disclaimer, or for generating custom outline numbering systems. CSS also includes some basic math functions for just such a purpose as custom outline numbering. This pseudo-element and the next are not well supported yet.

:after

This selector allows you to add CSS generated content to the end of an element.

:lang( )

This selector allows you to format based on the language being used in a specific element, or for the entire document. In order to work, the language must be specified in the document or element with a valid lang attribute or tag. The standard two character code for the language is specified in the parentheses, thus you would provide special stylnig for German with :lang(de).

:left

Only useful for style sheets for printing, this attribute specifies special formatting for the left hand (even numbered) pages.

:right

Only useful for style sheets for printing, this attribute specifies special formatting for the right hand (odd numbered) pages.