:nth-last-child() — counting elements from the end
The :nth-last-child() pseudo-class selects elements by their position counted backwards among siblings. Optional of S filters elements before counting.
CKTIS / CSS
Programming syntax, operators and concepts. Find an explanation, explore an example and return to learning.
The :nth-last-child() pseudo-class selects elements by their position counted backwards among siblings. Optional of S filters elements before counting.
The :nth-last-of-type() pseudo-class selects elements by their position among siblings of the same type, counting from the end.
The :nth-of-type() pseudo-class selects an element by its position among siblings of the same type, rather than among all element siblings. It supports 1-based positions, An+B formulas, and the keywords odd and even.
The :only-child pseudo-class selects an element without element siblings. Text and comments do not affect matching, but hidden elements do.
The :only-of-type pseudo-class selects an element with no siblings of the same type. Siblings of other types do not prevent a match; classes and IDs do not determine type.
The :open pseudo-class selects elements in their defined open state. Use it to style expanded details, open dialog elements, and controls with an open drop-down or picker.
The CSS :optional pseudo-class selects form controls that do not require a value. It does not mean “any element without required” or “an empty field”: matching depends on the control type and HTML rules.
The `:out-of-range` pseudo-class selects form controls whose value is below the lower limit or above the upper limit of their allowed range. In HTML, it applies to elements that participate in constraint validation and have range limitations; it does not represent every kind of invalid value.
The ::part() pseudo-element lets outside styles target shadow-tree elements explicitly exposed by a component.
The :past pseudo-class refers to earlier content on a timeline defined by the document language. In WebVTT, it can be used inside ::cue() to highlight a portion of an active cue once playback reaches the preceding timestamp, or from the start of the cue if there is no preceding timestamp. A match does not mean the portion has finished. It is not a selector for browsing history or dates.
The ::picker() pseudo-element targets the popup portion of a form control. For select, select::picker(select) lets you style the dropdown panel separately from the closed control. Both the control and its picker must opt into basic appearance.
The ::picker-icon pseudo-element styles the icon indicating that a popup picker is available. It does not represent the options panel itself.
The :picture-in-picture pseudo-class matches an element whose contents appear in an overlaid picture-in-picture window. It styles the element in the document, not the window itself.
The ::placeholder pseudo-element selects hint text in a form field, not the field itself or its entered value. It lets you change the hint’s appearance independently of user-entered text.
The :placeholder-shown pseudo-class selects a control currently displaying its placeholder hint. It lets you change the appearance of the whole field rather than just the placeholder text.
The :popover-open pseudo-class selects an element in its popover-showing state. It distinguishes that state from merely having the popover attribute, allowing styles to apply only while the popover is open.
The :read-only pseudo-class selects elements that are not user-editable under the document language’s rules. It is not equivalent to [readonly]: in HTML, it also matches ordinary paragraph elements and disabled fields. It does not match text nodes.
The :read-write pseudo-class selects elements whose contents the user can edit under HTML rules. It includes eligible form fields and editable content, but not every enabled control.
The CSS :required pseudo-class selects controls that HTML defines as required. It describes a requirement on a field, not whether its current value is valid or whether the field is empty.
The :right page pseudo-class selects right-hand pages in paginated output, such as printing. Use it in @page, typically to define asymmetric page margins.
The :root pseudo-class selects the document’s root element. In an ordinary HTML document, that element is html, not body.
The :scope pseudo-class identifies a selector’s scoping root. For example, it lets you select direct children of the element on which querySelectorAll() is called.
The ::scroll-button() pseudo-element provides a control that scrolls its associated container by one “page”. Its argument selects a direction, content generates the control, and :disabled identifies a scrolling boundary.
The ::scroll-marker pseudo-element creates a control that, when activated, scrolls to its originating element or, if it originates from a ::column pseudo-element, to that column. It requires a marker group on a scroll container.