Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

CSS :is Selector

CSS :is Selector

Complete CSS Selector Reference Manual Complete CSS Selector Reference Manual

Example

We want to apply styles to elements that contain

set the color for tags:

:is

(

p

)

{

color:

red

;

}

Try it »


Definition and usage

The CSS :is pseudo-class is a generic selector that allows you to combine multiple selectors together so they can be reused in CSS rules.

:is The pseudo-class can accept any number of selectors as arguments and returns the union of the elements matched by those selectors.

1. Combining element type selectors

:is(h1, h2, h3) {

    color: red;

}

This code sets the text color of all h1, h2, and h3 elements to red.

** 2. Combining class selectors**

:is(.highlight, .warning) {

    font-weight: bold;

}

This code sets the font weight to bold for all elements with the highlight or warning class.

3. Combining different types of selectors

:is(a[href^="https"], button[disabled]) {

    cursor: pointer;

}

This code sets the mouse cursor to a pointer for all links starting with https and buttons in the disabled state.

Note


Browser support

The numbers in the table indicate the first browser version that supports this property.

Selector
:invalid 10.0 10.0 4.0 5.0 10.0

CSS Syntax



:is(selector1, selector2, ..., selectorN) {

    /* Style rules */

}


Complete CSS Selector Reference Manual Complete CSS Selector Reference Manual