Menu

CSS TUTORIALS - CSS - Pseudo Classes

CSS - Pseudo Classes

ADVERTISEMENTS


selector:pseudo-class {property: value}

ADVERTISEMENTS


selector.class:pseudo-class {property: value}

ADVERTISEMENTS

ValueDescription
:linkUse this class to add special style to an unvisited link.
:visitedUse this class to add special style to a visited link.
:hoverUse this class to add special style to an element when you mouse over it.
:active Use this class to add special style to an active element.
:focusUse this class to add special style to an element while the element has focus.
:first-childUse this class to add special style to an element that is the first child of some other element.
:langUse this class to specify a language to use in a specified element.


<style type="text/css">
a:link {color:#000000}
</style>
<a href="/html/index.htm">Black Link</a>

Black Link


<style type="text/css">
a:visited {color: #006600}
</style>
<a href="/html/index.htm">Click this link</a>

Click this link


<style type="text/css">
a:hover {color: #FFCC00}
</style>
<a href="/html/index.htm">Bring Mouse Here</a>

Bring Mouse Here


<style type="text/css">
a:active {color: #FF00CC}
</style>
<a href="/html/index.htm">Click This Link</a>

Click This Link


<style type="text/css">
a:focus {color: #0000FF}
</style>
<a href="/html/index.htm">Click this Link</a>

Click This Link


<style type="text/css">
div > p:first-child
{
text-indent: 25px;
}
</style>
<div>
<p>
First paragraph in div. This paragraph will be indented
</p>
<p>
Second paragraph in div. This paragraph will not be  indented
</p>
</div>

But it will not match the paragraph in this HTML:

<div>
<h3>Heading</h3>
<p>
The first paragraph inside the div.
This paragraph will not be effected.
</p>
</div>

First paragraph in div. This paragraph will be indented

Second paragraph in div. This paragraph will not be indented

But it will not match the paragraph in this HTML:

Heading

The first paragraph inside the div.
This paragraph will not be effected.


<style type="text/css">
/* Two levels of quotes for two languages*/
:lang(en) { quotes: '"' '"'  "'"  "'"; }
:lang(fr) { quotes: "<<" ">>" "<" ">"; }
</style>
<p>...<q lang="fr">A quote in a paragraph</q>...</p>

...A quote in a paragraph...