
- CSS Tutorial
- CSS - Home
- CSS - Introduction
- CSS - Syntax
- CSS - Inclusion
- CSS - Measurement Units
- CSS - Colors
- CSS - Backgrounds
- CSS - Fonts
- CSS - Text
- CSS - Images
- CSS - Links
- CSS - Tables
- CSS - Borders
- CSS - Margins
- CSS - Lists
- CSS - Padding
- CSS - Cursors
- CSS - Outlines
- CSS - Dimension
- CSS - Scrollbars
- CSS Advanced
- CSS - Visibility
- CSS - Positioning
- CSS - Layers
- CSS - Pseudo Classes
- CSS - Pseudo Elements
- CSS - @ Rules
- CSS - Text Effects
- CSS - Media Types
- CSS - Paged Media
- CSS - Aural Media
- CSS - Printing
- CSS - Layouts
- CSS - Validations
- CSS3 Tutorial
- CSS3 - Tutorial
- CSS3 - Rounded Corner
- CSS3 - Border Images
- CSS3 - Multi Background
- CSS3 - Color
- CSS3 - Gradients
- CSS3 - Shadow
- CSS3 - Text
- CSS3 - Web font
- CSS3 - 2d transform
- CSS3 - 3d transform
- CSS3 - Animation
- CSS3 - Multi columns
- CSS3 - User Interface
- CSS3 - Box Sizing
- CSS Responsive
- CSS - Responsive Web Design
- CSS References
- CSS - Questions and Answers
- CSS - Quick Guide
- CSS - References
- CSS - Color References
- CSS - Web browser References
- CSS - Web safe fonts
- CSS - Units
- CSS - Animation
- CSS Resources
- CSS - Useful Resources
- CSS - Discussion
Pseudo-classes and all CSS Classes
The pseudo-class keywords are used to specify a special state of the selector to which it is added. This gives us more control and now we can target a selector when it is in specific state for e.g.: hover, checked, visited etc.
Following is the code demonstrating the pseudo classes in CSS −
Example
<!DOCTYPE html> <html> <head> <style> body { font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif; } a { font-size: 18px; font-weight: bold; } a:link { color: rgb(17, 0, 255); } a:visited { color: rgb(128, 0, 107); } a:hover { color: rgb(255, 105, 243); } a:active { color: rgb(255, 153, 0); } </style> </head> <body> <h1>Pseudo class example</h1> <a href="#">This is some sample link text</a> <h2>Hover , click on the above link to see the pseudo class in action</h2> </body> </html>
Output
The above code will produce the following output −
On hovering above the link −
On clicking the link −
Going back on the same page again, the link state changes to visited.
- Related Articles
- Pseudo-classes and CSS Classes
- Pseudo-elements and CSS Classes
- What are CSS pseudo-classes
- Anchor Pseudo-classes in CSS
- Working with CSS Pseudo Classes
- Commonly used pseudo-classes in CSS
- How to remove all CSS classes using jQuery?
- How to remove all CSS classes using jQuery?
- How to import all classes in Java?
- How do we use different CSS classes in HTML?
- What are the classes of breadcrumb in Materialize CSS?
- Classes and Objects in C++
- What is the difference between static classes and non-static inner classes in Java?
- PHP Anonymous classes
- PHP Autoloading Classes

Advertisements