CSS Selectors Reference

❮ Previous Home Next ❯

Selector Description
:active Specifies the link has been clicked(active link).
::after Sets a style to be used immediately following the element.
:any-link Acts as the source anchor of a hyperlink.
:any() Selects any element that can be selected by one of the selectors in that list.
[attribute] Select elements with the specified attribute.
[attribute^=value] Selects all elements of that have the attribute that begins with the given value.
[attribute*=value] Selects all elements of that have the attribute that contains the given value.
[attribute$=value] Selects all elements of that have the attribute that ends with the given value.
[attribute~=value] Select elements with an attribute value containing a specified word.
[attribute|=value] Select elements with the specified attribute starting with the specified value.
[attribute=value] Select elements with the specified attribute and value.
::backdrop Rendered immediately beneath any element being presented in fullscreen mode.
::before Sets a style to be used immediately before the element.
:blank Selects empty user input elements
:checked Selects the elements that are checked.
::cue Matches WebVTT cues within a selected element.
:current Represents an element or the ancestor of an element that is currently being displayed.
.class Selects all tags with the specified class value.
:default Selects the elements that are the default among a set of similar elements.
:defined Represents any element that has been defined.
:dir Selector matches elements based on the directionality of the text contained in them.
:disabled Selects the elements that are currently disabled.
element.class Specified elements of type selector(element) with a particular class value.
element,element Applies the same rules to a group of tags.
element element Selects descendent tags.
element>element Selects direct descendents.
element+element Selects adjacent siblings.
element1~element2 Selects preceding siblings.
element (type selector) Selects all element of the name specified in the rule.
:empty Selects an element that has no children.
:enabled Selects the elements that are currently enabled.
:first Represents the first page of a printed document.
:first-child Represents the first element among a group of sibling elements.
::first-letter (:first-letter) Applies styles to the first letter of the first line of a block-level element.
::first-line (:first-line) Applies styles to the first line of a block-level element.
:first-of-type Represents the first element of its type among a group of sibling elements.
:focus Matches any element that has keyboard input focus.
:focus-visible Applies while an element matches the :focus pseudo-class and the UA (User Agent) determines via heuristics that the focus should be made evident on the element.
:focus-within Matches an element if the element or any of its descendants are focused.
:fullscreen Matches every element which is currently in fullscreen mode.
:future Match for any element which appears entirely after an element that matches :current.
:has() Represents an element if any of the relative selectors that are passed as an argument match at least one element when anchored against this element.
:hover Matches when the user interacts with an element with a pointing device, but does not necessarily activate it.
#id Selects any tag with an id attribute set.
:in-range selector represents an <input> element whose current value is within the range limits specified by the min and max attributes.
:indeterminate Represents any form element whose state is indeterminate.
:invalid Selects any <form>, <fieldset>, <input> or other <form> element whose contents fail to validate.
:is() Selects any element that can be selected by one of the selectors in that list.
:lang Selects elements based on the language they are determined to be in.
:last-child Selects the element that is the last child of its parent.
:last-of-type Selects the element that is the last child of its parent that is of its type.
:left Sets page layout rules for a left-hand page when printing.
:link Specifies the unvisited link.
::marker Selects the marker box of a list item, which typically contains a bullet or number.
:matches Selects any element that can be selected by one of the selectors in that list.
:not() Selects elements that do not match the element/selector.
:nth-child Selects the element that is the nth child of its parent.
:nth-last-child Selects the element that is the nth from last child of its parent.
:nth-last-of-type Selects the element that is the nth-from-last child of its parent that is its type.
:nth-of-type Selects the element that is the nth child of its parent that is its type.
:only-child Selects an element if it’s the only child of its parent.
:only-of-type Selects an element if it’s the only child of its parent with its type.
:optional Selects <input> , <select>, or <textarea> element that does not have the required attribute set on it.
:out-of-range Represents an <input> element whose current value is out of the range limits specified by the min and max attributes.
::part() Represents any element within a shadow tree that has a matching part attribute.
:past Match for any element which appears entirely before an element that matches :current.
:paused Match an audio, video, or similar resource that is capable of being "played" or "paused", when that element is "paused".
:picture-in-picture Matches the element which is currently in picture-in-picture mode.
::placeholder Selects the placeholder text in an <input> or <textarea> element.
:placeholder-shown Selects <input> or <textarea> element that is currently displaying placeholder text.
:playing Match an audio, video, or similar resource that is capable of being "played" or "paused", when that element is "playing".
:read-only Selects an element that is not editable by the user.
:read-write Selects an element that is editable by the user.
:required Selects <input> , <select>, or <textarea> element that has the required attribute set on it.
:right Sets page layout rules for a right-hand page when printing.
:root Selects the root element of a tree representing the document.
:scope Represents elements that are a reference point for selectors to match against.
::selection Applies styles to the part of a document that has been highlighted by the user.
::slotted() Represents any element that has been placed into a slot inside an HTML template
:spelling-error Represents a text segment which the user agent has flagged as incorrectly spelled.
:target Selects a unique element (the target element) with an id matching the URL's fragment.
::target-text Represents the text that has been scrolled to if the browser supports text fragments. It allows authors to choose how to highlight that section of text.
:target-within Represents an element that is a target element or contains an element that is a target.
* (universal selector) Selects all elements
:valid Selects <input> or <form> element whose contents validate successfully.
:visited Specifies the link after being pressed.
:where() Selects any element that can be selected by one of the selectors in that list.
❮ Previous Home Next ❯