Pseudoclasses


Pseudoclasses are special classes that were defined for CSS. Pseudoclasses are defined with a colon followed by the name of the pseudoclass. Here is a list of the pseudoclasses.

Anchor

There are several pseudoclasses to accomodate anchors. link is an unvisited link. visited is a visited link. active is an active link.

Example:

A:link { color:red }
A:visited { color:blue }
A:active { color:green }
See this example. Note that the anchor pseudoclasses only affect the A tag, so it may be ommitted:
A:link { color:red }
:link { color:red }
These are equivalent.

If you wish to use it with another tag such as an IMG tag, you can do:

A:link IMG { color:blue }
You can also include pseudoclasses with normal classes. Example:
A.rollin:link { color:green }

<A class="rollin" HREF="http://www.netscape.com/">A link in a class by itself</A>

first-line

The first-line pseudoclass will affect the first line of text. Example:
<HTML>
<HEAD>
<STYLE type="text/css">
<!--
  P:first-line { color:green }
-->
</STYLE>
</HEAD>
<BODY>
<P >
This is a paragraph spread<BR>
over two lines.
</P>
</BODY>
</HTML>
See this example.

Note: Not yet supported by either browser?

first-letter

The first-letter pseudoclass will affect the first letter of text. Example:
<HTML>
<HEAD>
<STYLE type="text/css">
<!--
  P:first-letter { color:green }
-->
</STYLE>
</HEAD>
<BODY>
<P >
This is a paragraph spread<BR>
over two lines.
</P>
</BODY>
</HTML>
See this example.

Note: Not yet supported by either browser?


Previous Section
Nesting
Table of Contents Next Section
Including Files