Contact Number

+91 908 908 6161

Email Address

info@darlic.com

Sign up
Login

Learn with Darlic®
  • HTML
  • CSS
  • JQuery
  • Javascript
  • PHP
  • SQL
  • Tutorials
  • Courses

Pseudo-classes

Pseudo-classes

Posted on October 21, 2015 by

What are 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

Syntax

The syntax of pseudo-classes:

selector:pseudo-class {
    property:value;
}
Selector Example Example description
:active a:active Selects the active link
:checked input:checked Selects every checked <input> element
:disabled input:disabled Selects every disabled <input> element
:empty p:empty Selects every <p> element that has no children
:enabled input:enabled Selects every enabled <input> element
:first-child p:first-child Selects every <p> elements that is the first child of its parent
:focus input:focus Selects the <input> element that has focus
:hover a:hover Selects links on mouse over
:invalid input:invalid Selects all <input> elements with an invalid value
:last-child p:last-child Selects every <p> elements that is the last child of its parent
:link a:link Selects all unvisited links
:nth-child(n) p:nth-child(2) Selects every <p> element that is the second child of its parent
:only-child p:only-child Selects every <p> element that is the only child of its parent
:optional input:optional Selects <input> elements with no “required” attribute
:read-only input:read-only Selects <input> elements with a “readonly” attribute specified
:read-write input:read-write Selects <input> elements with no “readonly” attribute
:required input:required Selects <input> elements with a “required” attribute specified
:valid input:valid Selects all <input> elements with a valid value
:visited a:visited Selects all visited links

Post navigation

Previous
Next

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Empty Widget Area

About Darlic®

Darlic® is innovative platform to create websites, web applications, progressive web applications, mobile applications without a pain. Darlic® is registered Trademark of OXO IT SOLUTIONS PRIVATE LIMITED.

Links

  • Home
  • About
  • Features
  • Templates
  • Career
  • Blog
  • Contact

Resources

  • Documentation
  • Resources
  • Tools
  • Bits
  • Learn
  • Ask

Email Address

info@darlic.com

Contact Number

+91 908 908 6161

Social Links

Copyright Right
  • Privacy Policy
  • Terms and Condition