This content originally appeared on Manuel Matuzović - Blog and was authored by Manuel Matuzović
The :where()
and :is()
pseudo-classes allow you to write large lists of selectors in a more compact form. You can combine selectors instead of writing repetitive lists.
Combining input types
/* Before */
input[type="text"],
input[type="email"],
input[type="url"],
input[type="tel"],
input[type="password"],
input[type="search"] {
border: 2px solid;
}
/* After */
input:where(
[type="text"],
[type="email"],
[type="url"],
[type="tel"],
[type="password"],
[type="search"]
) {
border: 2px solid;
}
Combining pseudo-classes
a:is(:link, :visited) {
color: green;
}
a:is(:hover, :focus) {
text-decoration: none;
}
Now you might be thinking, “Uhm,…can’t I just use :where() instead of :is() and vice versa? What’s the difference?”.
A fantastic question that I’ll answer in tomorrows post! :)
My blog doesn't support comments yet, but you can reply via blog@matuzo.at.
This content originally appeared on Manuel Matuzović - Blog and was authored by Manuel Matuzović
Manuel Matuzović | Sciencx (2022-10-12T00:00:00+00:00) Day 13: the :where() and :is() pseudo-classes. Retrieved from https://www.scien.cx/2022/10/12/day-13-the-where-and-is-pseudo-classes-2/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.