on air

CSS Pseudo Format Class.

back home » Web Tutorials » CSS » CSS Pseudo Format Class.


Scenario.

Pseudo class allows the formatting of individual parts of an element's content. E.g. To format the first letter of a paragraph or a virgin hyperlink. The names of pseudo classes are restricted and cannot be selected freely as in the definitions of other selectors. Pseudo class allows different format definitions in various situations of a document or an Element.

Pseudo Classes :link and :visited [Hyperlinks].

  1. The pseudo class :link is responsible for the unvisited hyperlink. This CLASS treats the link as a virgin hyperlink so the user will be alarmed of its current status.
  2. The pseudo class :visited takes care of the visited hyperlink. This will treat the link as visited and will keep the user alarmed on its status. However, for some time the browser will reformat it to unvisited and its status will change for a virgin, [unvisited hyperlink]. The above two pseudo classes :link and :visited are only available for hyperlink element < a> with the Attribute <href> like this: <a href="#">.

In the illustration below, all unvisited hyperlinks will be formatted BLUE, while the visited hyperlinks will be RED.

a:link {color:#0000FF;}
a:visited{color:FF0000;}
    
/*The two classes above will 
functions only with hyperlinks. 
Defining the classes as the one 
below will function the 
same way as defined above. 
However, the above defined 
classes will function in most 
browsers better.*/
        
:link {color:#0000FF;}
:visited{color:FF0000;}

/*The above classes are only for 
hyperlinks like this
-- <a href="url">CLICK ME</a> --*/
  1. The pseudo class :hover will be activated when users move their mouse over an Element without clicking on it. This will change its color, expand it or behave with other dynamic effects, depending on its class definitions.
  2. The pseudo class :active will perform its act when a user activates an Element. E.g. when a user click on a hyperlink or a button, this will remain in an active status until the mouse is been released.
  3. The :focus class is used for Form Elements and or hyperlink. E.g., If you open a form, the cursor will be blinking in a textarea. This means that area has FOCUS, which is alarming you to type in here. Open your browser and press the tab key on your keyboard slowly and several times. You'll see that elements and hyperlinks in your browser will be getting FOCUS, alarming you to click here.

An Element or a hyperlink can be in different kinds of status at the same time. The last class format used by a user will be highlighted. E.g. a hyperlink can be in a visited status and yet, as active. For this reason, the class format definition here must be in the right listing, for a correct positioning of the pseudo classes. In this case, the visited status must come before the active.

See illustrator below.

a:link {color:red;}
a:visited {color:blue;}
 
a:hover {color:yellow;}
a:active{color:lime;}

Pseudo Classes :first-child and :last-child.

The pseudo class first-child will only format the first child Element of a parent Element.
The pseudo class last-child will only format the last child Element of a parent Element. In the illustrator below, you'll simply understand, the first child Element of the <body> Element <p> is being formatted red and underlined. You'll also see the last child Element, formatted blue and 20px.

See illustration below.

<style>
<!--
p:first-child{
text-decoration:underline; color:#FF0000;
}

p:last-child{
font-size:20px; color:#00F;
}
-->
</style>

<body>
<p>first child Element of the body tag,
I'll be formatted red with underlined.
</p>
  
<p>last child Element of the body tag 
I'll be formatted blue with 20px.
</p>
</body>

Pseudo Elements :first-line and :first-letter.

While Pseudo class always formats the whole of an Element, the Pseudo Element will match only a part of it. The Pseudo Elements :first line and :first letter, could be used only on a block Element that builds its own paragraphs. Whereby both Elements has the same CSS properties with different values. The first letter Element has priority.

Learn how and why from the illustration below.

<style>
<!--
p:first-line{
font-variant:small-caps; color:#F0F;
}

p:first-letter{
font-size:30px; color:#00F;
}
-->
</style>

<body>
<p>
First line of p Element is formatted 
small caps and colored magenta [pink].
First letter is formatted 30px, colored blue 
and will inherit also the first line format. 
It won't inherit the color value of first line 
because the first letter Element has priority.
Just take note of how the second line will 
change to use the browser default setting.
</p>
</body>

You may copy and paste the above script into a NOTEPAD. Save it as anyname.html and preview it in your choice of a browser.

More On CSS Pseudo Class Tutorial.

Clicks4UrMind

Man will give you worldly powers, and make you feel on top of all, note this is temporally and could be redrawn at anytime sending you back to the ground floor of life. However, the Lord Almighty, the one and the only rightful ruler of the Universe, blesses everlastingly.

Brain

Knowledge is Power, but Power is not Knowledge. Wisdom is the truthful Power that identifies the Knowledge within the man. And only, I repeat 3x. Only the almighty God has the power to bless the man with his Wisdom forever.

To achieve the Lord's blessings, cease not praying daily, asking for his Wisdom, and you'll be blessed abundantly...

SPYERA PHONE

Spyera Phone

Spyera Phone version is software that you install on a smart phone to monitor everything happening on the phone. After installation, SPYERA secretly records events (sms, call history, phone book, location, emails, What's App messages, IM, Facebook Chat, Skype, See photos taken and many more...) that happen on the phone and delivers these information to a web account, where you can view these reports 24/7 from any Internet enabled computer or mobile phone. SPYERA also allows you to listen to the surroundings of the target mobile , listen to the phone conversation and to know the location of the device.


Please, Kindly Donate What You Can, Enabling Us Pay Hosting And Domain Costing, And Do More.

Please Donate