Skip to content

Commit 2a6a668

Browse files
committed
:is()
1 parent a1919d0 commit 2a6a668

File tree

2 files changed

+26
-35
lines changed

2 files changed

+26
-35
lines changed

index.html

Lines changed: 10 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -14,40 +14,15 @@
1414
</head>
1515

1616
<body>
17-
<!-- Emmet Snippets -->
18-
<!-- h1 -->
19-
<h1></h1>
20-
<!-- h1.first -->
21-
<h1 class="first"></h1>
22-
<!-- h1.first.second -->
23-
<h1 class="first second"></h1>
24-
<!-- h1#first -->
25-
<h1 id="first"></h1>
26-
<!-- h1.first#second -->
27-
<h1 class="first" id="second"></h1>
28-
<!-- .first#third -->
29-
<div class="first" id="third"></div>
30-
<!-- ul>li -->
31-
<ul>
32-
<li></li>
33-
</ul>
34-
<!-- ul>li*5 -->
35-
<ul>
36-
<li></li>
37-
<li></li>
38-
<li></li>
39-
<li></li>
40-
<li></li>
41-
</ul>
42-
<!-- h1{hello world} -->
43-
<h1>hello world</h1>
44-
<!-- ul>li*5{$ hello world} -->
45-
<ul>
46-
<li>1 hello world</li>
47-
<li>2 hello world</li>
48-
<li>3 hello world</li>
49-
<li>4 hello world</li>
50-
<li>5 hello world</li>
51-
</ul>
17+
<nav>
18+
<h2>heading</h2>
19+
</nav>
20+
<div>
21+
<h2>heading</h2>
22+
</div>
23+
<section>
24+
<h2>heading</h2>
25+
</section>
26+
<h2>heading</h2>
5227
</body>
5328
</html>

styles.css

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/*
2+
:is()
3+
The :is() CSS pseudo-class function takes a selector list as its argument, and selects any element that can be selected by one of the selectors in that list.
4+
*/
5+
6+
/* Want to add color red to h2 only which is inside the elements */
7+
/* nav h2:hover,
8+
div h2:hover,
9+
section h2:hover {
10+
color: red;
11+
} */
12+
13+
/* write less code using is:() */
14+
:is(nav, div, section) h2:hover {
15+
color: red;
16+
}

0 commit comments

Comments
 (0)