The :is pseudo-class


The “:is” pseudo-class is a new addition to the CSS Selectors Level 4 specification, and it allows you to style elements based on their state. This means that you can use the “:is” pseudo-class to change the styling of an element when it’s in a specific state, such as when it’s hovered or focused.

One of the most powerful features of the “:is” pseudo-class is that it allows you to group multiple selectors together and apply styles to them all at once. This can greatly simplify your CSS and make it more maintainable. For example, you can use the “:is” pseudo-class to group together several button styles like this:

:is(button, .button, input[type="button"]) {
    padding: 10px 20px;
    background-color: blue;
    color: white;
    border-radius: 5px;
    text-align: center;
    cursor: pointer;

This code will apply the same styles to all elements that match the selector “button”, “.button”, or “input[type=’button’]”. This can save a lot of time and make it easy to keep all your button styles consistent across your website.

Another advantage of :is is that it can be used to change an element’s appearance based on the state of a different element. This can be done using the :is notation to reference other elements or conditions that can be met by an element, for example:

:is(:hover) label {
    color: red;

Browser Support

It is important to keep in mind that :is is not supported by all browsers, but that can change as more browsers implement it.

In summary, the “:is” pseudo-class is a powerful new feature in CSS that allows you to style elements based on their state, group multiple selectors together, and change the appearance of one element based on the state of another. It allows for more maintainable and efficient CSS, but currently it may not be supported by all browsers yet. As a developer, it’s important to keep an eye out for new features like this and be ready to use them when they are more widely adopted.

Facebook Comments