CSS Selectors and Pseudo-classes allow you to target specific elements on a page based on their state, position, or attributes. Browse all 122 selectors in our CSS Reference.
Creates a 'virtual' element that appears as the last child of the selected element. It's commonly used for decorative elements like icons, dividers or tooltips without adding extra HTML tags.
97%Widely availableStyles the area behind a full-screen element or dialog. It allows you to dim the background or add effects like blur when a modal is active.
97%Widely availableCreates a 'virtual' element that appears as the first child of the selected element. It's often used for quotes, bullet icons or other decorative elements that don't need to be in the HTML markup.
97%Widely availableAn experimental pseudo-element part of the customizable select API that allows styling the checkmark icon in dropdown menus.
72%Limited availabilityAn experimental pseudo-element that allows you to style individual column boxes in a multi-column layout.
71%Limited availabilityA pseudo-element that styles WebVTT (Web Video Text Tracks) cues, such as subtitles or captions, in a video or audio element.
97%Widely availableA pseudo-element that targets the content part of a <details> element (the part that expands and collapses), so you can style or animate it.
89%Newly availableA pseudo-element that targets the button part of an '<input type="file">' element, allowing you to style the 'upload' button directly.
97%Widely availableA pseudo-element that targets the very first letter of the first line of a block-level element. Handy for drop caps.
97%Widely availableA pseudo-element that targets the entire first line of text within a block-level element. The line length changes as the browser window is resized.
97%Widely availableMatches text that the browser has flagged as having a grammatical error. You can use this to change the color or style of the grammar correction underline.
89%Newly availableTargets custom text highlights created via the CSS Highlight API. It allows you to style specific ranges of text programmatically (ideal for search-and-highlight features).
95%Newly availableTargets the list item marker (usually the bullet point or number) of a list element. It allows you to style the bullet separately from the text of the list item.
97%Limited availabilityA selector used inside a Shadow DOM that allows you to style specific internal pieces of a web component from the outside (the 'global' CSS).
97%Widely availableA pseudo-element selector part of the new customizable <select> API. it allows you to style the actual dropdown menu (the 'picker') that appears when you click a select box.
72%Limited availabilityA pseudo-element selector part of the new customizable <select> API. It identifies the icon or arrow that users click to open a selection menu.
72%Limited availabilityA pseudo-element selector that lets you style the actual text of a placeholder inside an input field.
97%Widely availableA new pseudo-element that allows you to style the 'up', 'down', 'left' and 'right' buttons that appear in scrollable containers (like scrollbars).
71%Limited availabilityA new experimental pseudo-element that represents an individual navigation dot in a carousel. You can style these dots (like an active/inactive state) directly in CSS.
71%Limited availabilityA pseudo-element that holds a scroller's scroll markers, the dots or tabs that jump to each item. The scroll-marker-group property on the scroller creates it. It works in Chrome and Edge so far.
71%Limited availabilityA pseudo-element that allows you to style text that matches a 'find in page' search query. This lets you customize how highlighted search results appear in your site.
68%Limited availabilityA pseudo-element that styles the part of a document that has been highlighted by the user (usually by clicking and dragging with the mouse).
82%Limited availabilityA pseudo-element used inside a Web Component (Shadow DOM) to style elements that have been 'slotted' into a <slot> tag from the light DOM.
97%Widely availableA pseudo-element that allows you to customize the styling of words that the browser identifies as having spelling errors.
89%Newly availableA pseudo-element that allows you to style text that has been targeted via a URL fragment (the part after the # in a URL). This is often used for 'scrol-to-text' highlights.
94%Newly availableThe root of the pseudo-element tree the browser builds during a view transition. It sits on top of the page and holds every ::view-transition-group(), so styles here apply to the whole transition layer.
94%Newly availableTargets the transition 'group' container for a specific named view transition. This is the container that holds both the 'old' and 'new' snapshots of an element, allowing you to animate the entire group as it moves or scales.
94%Newly availableTargets the 'pair' of images (the old snapshot and the new snapshot) within a view transition group. This is where the cross-fade between the two states actually happens.
94%Newly availableTargets the 'new' state's snapshot in a view transition. This is the image of how the element looks AFTER the change, allowing you to specifically animate how it fades in.
94%Newly availableTargets the 'old' state's snapshot in a view transition. This is the image of how the element looked BEFORE the change, allowing you to animate how it fades out or is removed.
94%Newly availableMatches an element while it is actively being clicked or tapped. It's often used to give visual feedback (like a slight 'press' down effect) to the user.
97%Widely availableMatches elements that are currently participating in a view transition. This allows you to apply specific styles or animations exclusively while the transition is in progress.
90%Newly availableAllows you to target elements during a specific type of view transition. By naming your transitions (e.g., 'slide-in' or 'payout'), you can apply different styles for each scenario.
90%Newly availableMatches both :link and :visited pseudo-classes. Selects any hyperlink regardless of visited state.
97%Widely availableAllows you to select elements based on the presence or value of their HTML attributes. It's handy for styling elements like inputs with specific types or links pointing to PDF files.
97%Widely availableMatches an input element when its value has been automatically filled by the browser (like an address or credit card). It's useful for overriding the browser's default yellow background in autofilled fields.
97%Limited availabilityTargets media elements (like <video> or <audio>) while they are actively loading data and currently 'buffering'.
20%Limited availabilityA pseudo-class that targets checkboxes, radio buttons or option elements that are currently selected (checked) by the user.
97%Widely availableThe child combinator (>) selects elements that are immediate children of a specific parent, ignoring grandchildren or further descendants.
97%Widely availableThe class selector (.) targets all elements that have a specific 'class' attribute. It is the most common and flexible way to apply styles in CSS.
97%Widely availableA pseudo-class that targets form elements (like buttons or checkboxes) that are the default among a set of similar elements.
97%Widely availableMatches any element that has been officially 'defined' by the browser. This includes all standard HTML elements and any custom elements that have been registered via JavaScript.
97%Widely availableThe most common CSS combinator (a simple space). It targets an element that is inside (a descendant of) another specified element, no matter how deeply nested.
97%Widely availableMatches elements based on text direction (ltr or rtl). Useful for bi-directional text layouts.
94%Widely availableA pseudo-class that targets elements that are in a disabled state (like a button with the 'disabled' attribute), making them unclickable and often grayed out.
97%Widely availableA pseudo-class that targets any element that has absolutely no content inside it (not even whitespace or children).
97%Widely availableA pseudo-class that targets form elements (like inputs or buttons) that are in an 'enabled' state and can be interacted with.
97%Widely availableA page-target selector used within the '@page' rule to specifically style the first page of a printed document.
97%Widely availableA pseudo-class that targets an element only if it is the very first child of its parent.
97%Widely availableA pseudo-class that targets the first element of its specific type within a parent. For example, 'p:first-of-type' targets the first paragraph, even if it's not the first overall child.
97%Widely availableA pseudo-class that targets an element that has been selected (e.g., clicked or tabbed to) and is ready to receive input.
97%Widely availableStyles focus indicator only when keyboard navigation is used. Hides focus ring for mouse users.
96%Widely availableMatches an element if it or any of its descendants have focus. Useful for form container styling.
97%Widely availableTargets an element while it is being displayed in the browser's full-screen mode (e.g., when a video or a photo is expanded to fill the whole monitor).
97%Limited availabilityA pseudo-class used with WebVTT (video subtitles). It targets subtitle cues that are scheduled to appear 'in the future' relative to the current playback time.
94%Limited availabilityMatches a 'slot' in the Shadow DOM if it contains content that matches the selector. It's used within Web Components to style slots based on what's been put inside them.
2%Limited availabilityMatches an element if it contains at least one descendant or preceding element that matches the selector provided in the arguments. It is often referred to as the 'parent selector'.
Snippet →96%Widely availableAn experimental pseudo-class that targets any heading element (h1, h2, h3, h4, h5 or h6) automatically.
1%Limited availabilityA pseudo-class used in Web Components to style the custom element based on its position in the outside page (e.g., styling a component differently if it's placed inside a 'dark-mode' container).
76%Limited availabilityAllows you to style the 'host' (the custom element itself) from within the element's own Shadow DOM. It's the standard way to set a component's default display, width or height.
97%Widely availableUsed inside a Shadow DOM to style the 'host' element (the custom element itself). The functional version ':host()' lets you apply styles only if the host matches a specific selector.
97%Widely availableTargets an element when the user's cursor is positioned over it. It's the bread-and-butter for making interactive buttons and links.
97%Widely availableTargets a single, unique element on a page that has a matching 'id' attribute. Since IDs must be unique, this selector should only ever match one element.
97%Widely availableTargets form inputs (like type='number') whose current value is between the minimum and maximum limits set by 'min' and 'max' attributes.
97%Widely availableTargets form elements whose state is neither 'on' nor 'off' (like a checkbox that's been mixed by JavaScript, or a radio group where nothing is selected yet).
97%Widely availableExperimental: Targets an element that is currently the 'source' of interest (the element being hovered or focused) which is triggering an interest-based UI like a tooltip.
70%Limited availabilityExperimental: Targets the 'target' of an interest action (like the tooltip or popover itself) while it is currently being shown.
70%Limited availabilityTargets form inputs that contain data that doesn't follow the rules set by attributes like 'required', 'pattern' or 'type'.
97%Widely availableMatches any selector in its argument list. Useful for grouping related selectors.
97%Widely availableMatches elements by language. Use to style different languages differently without adding classes.
97%Widely availableTargets an element only if it is the very last child inside its parent container.
97%Widely availableTargets the last element of a specific type (like the last <p> or the last <img>) within its parent container, even if there are other types of elements after it.
97%Widely availableA selector used inside the @page rule to target the physical 'left' pages of a double-sided printed document.
94%Limited availabilityTargets links (<a> elements with an 'href') that have not yet been visited by the user.
97%Widely availableA selector list is simply a comma-separated list of multiple selectors. If an element matches any one of the selectors in the list, the styles will be applied to it.
97%Widely availableA selector that matches a media element (like <video> or <audio>) when it is currently set to play back in a loop.
0%Limited availabilityTargets an element that is in a 'modal' state, such as a <dialog> element opened with the showModal() method.
96%Widely availableTargets media elements (like <video> or <audio>) when they are currently muted.
20%Limited availabilityTargets an element that is immediately following another element at the same level in the HTML structure.
97%Widely availableMatches elements that do not match the list of selectors provided in its arguments. It allows you to exclude specific items from a general style rule.
97%Widely availableTargets elements based on their position in a list. You can use numbers, formulas (like 2n for 'every second'), or keywords like 'odd' and 'even'.
97%Widely availableWorks exactly like :nth-child(), but it counts backwards from the very last element in the container.
97%Widely availableTargets elements of a specific type (like <p>) by counting backwards from the last one of that type in the container.
97%Widely availableTargets elements based on their position among siblings of the same type. For example, it can target 'the second image' even if there are paragraphs in between.
97%Widely availableTargets an element that is the ONLY child of its parent. If there are any other elements (even of a different type), it won't match.
97%Widely availableTargets an element that is the ONLY child of its type among its siblings. For example, 'the only image' in a div, even if there's also text.
97%Widely availableTargets elements that are currently in an 'open' state, such as a <details> element that is expanded or a <dialog> that is visible.
Snippet →89%Newly availableTargets form elements (like <input> or <select>) that do NOT have the 'required' attribute.
97%Widely availableTargets form inputs when their value is outside the limits specified by 'min' or 'max' attributes (for example, typing 11 in a 1-10 range input).
97%Widely availableA selector used with WebVTT subtitles to style the text that has already been spoken in the current video caption.
94%Limited availabilityA selector that matches a media element (like <video> or <audio>) when it is currently paused.
20%Limited availabilityA selector that matches a media element (like <video>) when it is currently being played in a floating 'picture-in-picture' window.
94%Limited availabilityA selector that matches an <input> or <textarea> element ONLY while it is currently showing its placeholder text (meaning the field is empty).
97%Widely availableA selector that matches a media element (like <video> or <audio>) when it is currently playing.
20%Limited availabilityMatches elements with the popover attribute that are currently in their open state. It allows you to style top-layer content like menus and tooltips specifically when they are visible.
94%Widely availableA selector that matches elements (like inputs) that cannot be edited by the user. This includes fields with the 'readonly' attribute or contenteditable fields that are disabled.
97%Widely availableA selector that matches elements that ARE editable by the user. This includes normal text inputs, textareas or elements with 'contenteditable' turned on.
97%Widely availableA selector that matches any <input>, <select> or <textarea> element that has the 'required' attribute set. It's often used to show a red asterisk or border on mandatory fields.
97%Widely availableA selector used in paged media (like printing) to style only the right-hand pages of a document (usually odd-numbered pages).
94%Limited availabilityA selector that matches the very top-level element of the document (usually the <html> tag in a website). It's the standard place to define global CSS variables.
97%Widely availableTargets the element that is the scope of the selector. In stylesheet CSS this is usually the document root. Inside @scope it is the scoped root.
88%Widely availableA selector that matches a media element (like <video> or <audio>) while the user is actively 'seeking' or scrubbing through the timeline.
20%Limited availabilityA selector that matches a media element (like <video> or <audio>) when it tries to fetch data but can't because of a slow network or connection issues.
20%Limited availabilityA pseudo-class for Custom Elements that allows you to style them based on custom internal states (like 'loading', 'active' or 'error') that are set via JavaScript using the ElementInternals API.
95%Newly availableMatched by the '~' symbol, this selector targets any siblings that come AFTER the specified element in the HTML. It doesn't have to be the very next sibling.
97%Widely availableMatches the element referenced by a URL fragment. Highlights the element when directly linked to.
97%Widely availableAn experimental pseudo-class that matches a 'scroll marker' when it represents an item that comes AFTER the current viewport in a scroll container.
70%Limited availabilityAn experimental pseudo-class that matches a 'scroll marker' when it represents an item that comes BEFORE the current viewport in a scroll container.
70%Limited availabilityAn experimental pseudo-class that matches the 'scroll marker' corresponding to the item currently visible in the viewport. This is the 'active' state for carousel indicators.
71%Limited availabilityThe 'asterisk' selector that matches every single element on the page. It is commonly used in CSS resets to apply a base style (like 'box-sizing: border-box') to everything at once.
97%Widely availableMatches input elements after the user has modified them and they are invalid. Shows validation errors to users.
94%Widely availableMatches input elements after the user has modified them and they are valid. Provides user-driven validation feedback.
94%Widely availableTargets any form element that currently meets its requirements (like matching a 'pattern' or having content in a 'required' field). Unlike ':user-valid', this can match immediately on page load.
97%Widely availableMatches any link that the user has already visited in their browser. For privacy reasons, the browser only allows you to change a few specific properties (like 'color' and 'background-color') using this selector.
97%Widely availableAn experimental pseudo-class that targets audio or video elements that are currently 'locked' from being muted or having their volume changed (often seen in certain accessibility contexts).
20%Limited availabilityLike :is() but with zero specificity. Lets you style without affecting selector specificity.
97%Widely availableAllows you to write CSS rules inside of other rules. This makes your code more organized and mirrors the structure of your HTML.
Snippet →94%Widely availableAn experimental pseudo-class function that targets a heading of a specific level or relative level (e.g., :heading(2) for h2).
N/ALimited availabilityThe vertical bar puts a type selector in a namespace declared with @namespace. svg|a matches only SVG a elements, while *|a matches a elements in any namespace.
97%Widely availableMatches every element with a given tag name, like p, h1 or button. Its specificity is low, so a class or ID selector beats it.
97%Widely availableAn experimental selector used in the View Transition API to target and style the children within a view transition group.
70%Limited availabilityAn experimental pseudo-class that targets the root element of a 'DOM Overlay' when a web page is being viewed in an Immersive AR or VR environment.
76%Limited availabilityNothing matches.