In this tutorial you will learn about pseudo classes defined in CSS, including various properties and its implementation.
Listing 1: Script of anchor classes.
<html>
<head>
<title>introduction to pseudo classes</title>
<style type="text/css">
a:link
{color: green;
color:#b50010;
text-decoration: none;}
a:visited {
color: blue;
background:#804180;
text-decoration: none;}
a:hover{
color: gray;
background : #ffff00;
text-decoration: none;
}
a:active {color: black;}
</style>
</head>
<body>
<a href="http://www.facebook.com" target="_blank">Homepage of facebook</a>
<br />
<a href="http://www.orkut.com" target="_blank">Homepage of orkut</a>
<br />
<a href="http://www.gmail.com" target="_blank">Login page of gmail</a>
<br />
<a href="http://www.rediffmail.com" target="_blank">Rediffmail page</a>
</body>
</html>

Figure 1: Above figure is output of described classes in initial version of CSS which explained how the state's name in the "pseudo class," that defines how the HTML element should appear, depending on the state it is in.
It is very useful for designers who work with multi-language sites. With this pseudo-class you can write CSS selectors that match based on what language the element is written. One can use it to change the font of the pages or make other changes depending upon the language on the page. It should be kept in mind that in Internet explorer :lang pseudo class supports only if <!Doctype> is mentioned. Following example will cover the concept of lang pseudo classes.
Listing 2: Script of Lang pseudo classes
<html>
<head>
<style type="text/css">
/* This is two stage of different language*/
:lang(en) { quotes: '"' '"' "'" "'"; }
:lang(fr) { quotes: "<" ">" "<" ">"; }
</style>
<p>...<q lang="fr">Americas cover 8.3% of the Earth's total surface area</q>...</p>
</body>
</html>
Figure 2:Above figure shows output of :lang pseudo class script for two different languages.
The :first-child pseudo-class matches a specified element that is the first child of another element and like lang pseudo class Internet explorer will support only if <!Doctype> is mentioned in script. Following script compiles idea of first child class.
Listing 3: Script of First child class
<html>
<head>
<style type="text/css">
p:first-child
{background : #804180;}
</style>
</head>
<body>
<p>My definition of hard work is that which challenges you</p>
<p>My definition of hard work is that which challenges you</p>
</body>
</html>
Figure 3: above figure is output of first child pseudo class tutorial in which the selector matches any “<p>” element that is the first child of any element:
Second example describes how the selector matches the first “<n>” element in all “<p>” elements. Same condition hold for Internet explorer like other classes.
Listing 4: Script - matches the first <n> element in all <p> elements.
<html>
<head>
<style type="text/css">
p >n:first-child
{background : #b50010;}
</style>
</head>
<body>
<p>The big secret
<n>in life is</n>
that there is
</n> no big secret</p>
<p>The big secret
<n>in life is
</n>that there is
</n> no big secret</p>
</body>
</html>

Figure 4: Above figure is output of script of which explained how to match the first “<n>” element in all “<p>” elements.
Similar to third, example description is how to match all <n> elements in all first child <p> elements
Listing 5: Script of Matching all <n> elements in all first child <p> elements
<html>
<head>
<style type="text/css">
p:first-child n
{
background:green;
}
</style>
</head>
<body>
<p> The World <n>Health Organization</n> (WHO) is a <n>specialized agency of</n> the United Nations </p>
<p> The World <n>Health Organization</n> (WHO) is a <n>specialized agency of</n> the United Nations </p>
</body>
</html>

This tutorial covered almost all fundamental topics related to Pseudo classes but there are various kind of selector terminology , Pseudo classes, which describes many more classes and adding different styles to hyperlinks as well.
You can explore the other functionalities of Pseudo classes and comment here in case of any questions.








See the prices for this post in Mr.Bool Credits System below: