Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pseudo-Class tip added #168

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ A collection of tips to help take your CSS skills pro.
1. [Use Pointer Events to Control Mouse Events](#use-pointer-events-to-control-mouse-events)
1. [Set `display: none` on Line Breaks Used as Spacing](#set-display-none-on-line-breaks-used-as-spacing)
1. [Use `:empty` to Hide Empty HTML Elements](#use-empty-to-hide-empty-html-elements)
1. [Use `:is` for Selecting Multiple Elements](#use-is-for-selecting-multiple-elements)


### Use a CSS Reset
Expand Down Expand Up @@ -640,6 +641,28 @@ If you have HTML elements that are empty, i.e., the content has yet to be set ei
<sup>[back to table of contents](#table-of-contents)</sup>


### Use `:is` for Selecting Mulitple Elements

If you have multiple selectors, and you want to give same css, you can use this pseudo-class. The `:is()` function takes precedence over other selectors, so you can use it to override styles set by other selectors.

```css
.highlights {
background-color: blue;
}

:is(.highlights) {
background-color: yellow;
font-weight: bold;
}
```

Morever you can use the `:is()` function to select multiple elements at once, by combining selectors in the parentheses. For example: `:is(h1, p)` will select all elements with either the tags `"h1"` or the `"p"`.

#### [Demo](https://codepen.io/khan_zada22/pen/bGjJXZQ)

<sup>[back to table of contents](#table-of-contents)</sup>


## Support

Current versions of Chrome, Firefox, Safari, Opera, Edge, and IE11.
Expand Down