CSS - Pseudo Class Selector

CSS Pseudo Class Selector

This selector, selects a particular state of position of an element.

  • It is denoted by the element, followed by one colon ( : ) and the state or position.

Pseudo Classes

SELECTORS DESCRIPTION
:active

Selects the active link

:checked

Selects all checked <input> element

:disabled

Selects all disabled <input> element

:empty

Selects all the elements that has no content.

:enabled

Selects all enabled <input> element

:first-child

Selects all the first element inside every parent element.

:first-of-type

Selects all the element that is the first child of a particular type of its parent.

:focus

Selects the <input> elements when it gets focused.

:hover

Selects element when you mouse over it.

:in-range

Selects the <input> elements that has a value within a specified range.

:invalid

Selects all <input> elements that has an invalid value.

:lang

Selects all the element with the language attribute value. E.g. p:(lang(it)).

:last-child

Selects all the last element inside every parent element.

:last-type-of

Selects all the element that is the last child of a particular type of its parent.

:link

Selects all unvisited links

:not(selector)

Selects all the element that is not the specified element.

:nth-child(n)

Selects all the child element of the specified position inside the parent element.

:nth-last-child(n)

Starting from the last child, selects all the last element of the specified position inside the parent element.

:nth-last-of-type(n)

Counting from the last type, select all the element that is the last child of the specified position (of a particular type) inside of its parent element.

:nth-of-type(n)

Selects all the element of the specified position (of a particular type) inside of its parent element.

:only-of-type

Selects the element of a particular type that is the only one inside its parent element.

:only-child

Selects all the element that is the only child of its parent element.

:optional

Selects all <input> elements that has no required attribute.

:out-of-range

Selects all <input> elements that has a value outside the specified range.

:readonly

Selects all <input> elements that has readonly attribute.

:read-write

Selects all <input> elements that has NO readonly attribute.

:required

Selects all <input> elements that has required attribute.

:root

Selects the document root element.

:target

Selects the current active target link.

:valid

Selects all <input> elements that has a valid value.

:visited

Selects all visited links.

ADVERTISEMENTS

LEARNING IS A CONTINOUS PROCESS - PRACTICE MAKES PERFECT