CSS Properties

Pseudo-class Properties

A pseudo-class is used to define a special state of an element.

Syntax:

selector:pseudo-class {
property:value;
}

Types of pseudo-class

  • :link
  • :visited
  • :hover
  • :active
  • :focus
  • :checked
  • :first-child
  • :first-of-type
  • :nth-child(n)
:link

link - a normal, unvisited link

a:link {
color: re
d; }


:visited

visited - a link the user has visited

a:visited {
color: red;
}


:hover

hover - a link when the user mouse over it

a:hover {
color: red
; }


:active

active - a link the moment it is clicked

a:active {
color: red;
}


Note
  • a:hover MUST come after a:link and a:visited
  • a:active MUST come after a:hover
first-child

This will set CSS rule to every first element of selector which is someone’s child.

last-child

This will set CSS rule to every last element of selector which is someone’s child.

first-of-type

This will set CSS rule to every first selector type of element.

last-of-type

This will set CSS rule to every last selector type of element.

Cristle Academy

Compiler