Pseudo Classes
A pseudo class is used to define a special state of an element.
For example, it can be used to:
• Style an element when a user mouses over it
• Style visited and unvisited links differently
• Style an element when it gets focus
Types of Pseudo Classes
Selector Example Description
:active a:active Selects the active link
:checked input:checked Selects every checked <input> element
:empty p:empty Selects every <p> element that has no children
:first-child p:first-child Selects every <p> elements that is the first child of its
parent
:hover a:hover Selects links on mouse over
:visited a:visited Selects all visited links
:empty p:empty Selects every <p> element that has no
children
Types of Pseudo Classes
For Example
Difference between Class and Pseudo Class
Class Pseudo Class
A class is used to define property of A pseudo class is used to define a
an HTML element when a webpage special state of an element which
is opened and it is viewed at the first will happen once you do some
place. activity on the webpage.
Class is defined using a dot(.). A pseudo class is defined using a
colon(:).
Example
Thank You