Powered by Blogger.

CSS Pseudo-classes

 


CSS pseudo-classes are used to give some special effects to some selectors.
There are various CSS pseudo-classes element.

SelectorExampleExample description
:linka:linkSelects all unvisited links
:visiteda:visitedSelects all visited links
:activea:activeSelects the active link
:hovera:hoverSelects links on mouse over
:focusinput:focusSelects the input element which has focus
::first-letterp::first-letterSelects the first letter of every element
::first-linep::first-lineSelects the first line of every element
:first-childp:first-childSelects every elements that is the first child of its parent
::beforep::beforeInsert content before every element
::afterp::afterInsert content after every element
:lang(language)p:lang(it)Selects every element with a lang attribute value starting with "it"


One Exaple for matches the first <i> element in all <p> elements by using first child selector.


I am a cool man. I am not a angry man.
I am a cool man. I am a angry man.

HTML Content

    I am a cool man. I am not a angry man.


I am a cool man. I am a angry man.



CSS Content

p > i:first-child {
    color: blue;
} 

No comments