CSS Worksheet: Selectors Class and Id
Code tip (Dot for class, hash for id): p matches every <p>; .note matches class="note"; #top matches id="top". A dot means class, a hash means id — mixing them up matches nothing. Many elements can share a class; an id belongs to only one element.
NameDateTime takenScore ___ / 40
- 1.🎯 What kind of selector is h1? (a) an id selector (b) an element selector (c) a class selector
-
2.🎯 Which CSS selector matches this element?
<p class="red" id="intro">Hello</p> (a) #main (b) .intro (c) h1 (d) p - 3.🎯 How many elements on a page should have the same id? (a) 5 (b) 1 (c) any number (d) 2
- 4.🎯 Can many elements share the same class? (a) Yes (b) No
-
5.🎯 Which CSS selector matches this element?
<h1 class="box" id="hero">Hello</h1> (a) #box (b) .star (c) h2 (d) .box -
6.🎯 Which CSS selector matches this element?
<li class="big" id="intro">Hello</li> (a) div (b) li (c) .intro (d) #big - 7.🎯 Which element does the selector h2 style? (a) <span id="top"> (b) <li> (c) <h2 class="note"> (d) <div class="note">
- 8.🎯 What kind of selector is #logo? (a) a class selector (b) an id selector (c) an element selector
- 9.🎯 Which sign starts an id selector? (a) . (b) @ (c) & (d) #
- 10.🎯 Which element does the selector h1 style? (a) <h2> (b) <div id="end"> (c) <h1 class="note"> (d) <li class="note">
-
11.🎯 Which CSS selector matches this element?
<div class="box" id="hero">Hello</div> (a) span (b) .hero (c) #top (d) .box -
12.🎯 Which CSS selector matches this element?
<li class="big" id="main">Hello</li> (a) #logo (b) .red (c) #main (d) #big - 13.True or false: #main is a class selector. (a) True (b) False
- 14.True or false: img is an id selector. (a) True (b) False
- 15.True or false: body is an id selector. (a) False (b) True
- 16.True or false: h1 is an element selector. (a) True (b) False
- 17.🎯 Which element does the selector .note style? (a) <h2 class="red"> (b) <h1 class="note"> (c) <h1 id="note"> (d) <h1 class="big">
-
18.🎯 Which CSS selector matches this element?
<h1 class="note" id="top">Hello</h1> (a) h2 (b) #note (c) #top (d) .big - 19.True or false: body is an element selector. (a) False (b) True
-
20.🎯 Which CSS selector matches this element?
<p class="menu" id="end">Hello</p> (a) .end (b) #menu (c) #hero (d) p -
21.🎯 Which CSS selector matches this element?
<p class="menu" id="intro">Hello</p> (a) p (b) #menu (c) .intro (d) h1 - 22.🎯 Which sign starts a class selector? (a) # (b) @ (c) & (d) .
-
23.🎯 Which CSS selector matches this element?
<span class="box" id="hero">Hello</span> (a) p (b) .star (c) #hero (d) .hero - 24.True or false: .big is a class selector. (a) False (b) True
- 25.🎯 Which element does the selector p style? (a) <p class="note"> (b) <h2 class="note"> (c) <li id="top"> (d) <h1>
- 26.True or false: #hero is an id selector. (a) True (b) False
-
27.🎯 Which CSS selector matches this element?
<span class="box" id="end">Hello</span> (a) #box (b) #hero (c) .box (d) .end -
28.🎯 Which CSS selector matches this element?
<h1 class="box" id="top">Hello</h1> (a) .star (b) #intro (c) h1 (d) #box -
29.🎯 Which CSS selector matches this element?
<li class="box" id="main">Hello</li> (a) .main (b) #logo (c) .star (d) .box - 30.True or false: #top is an id selector. (a) True (b) False
-
31.🎯 Which CSS selector matches this element?
<span class="note" id="logo">Hello</span> (a) #end (b) #note (c) #logo (d) p - 32.🎯 Which element does the selector div style? (a) <h1 id="main"> (b) <p class="note"> (c) <div class="note"> (d) <span>
- 33.🎯 Which element does the selector p style? (a) <h2 class="box"> (b) <li id="top"> (c) <p class="box"> (d) <h1>
- 34.True or false: .star is a class selector. (a) False (b) True
- 35.🎯 What kind of selector is #hero? (a) an element selector (b) a class selector (c) an id selector
-
36.🎯 Which CSS selector matches this element?
<li class="note" id="top">Hello</li> (a) div (b) .big (c) .top (d) .note -
37.🎯 Which CSS selector matches this element?
<h1 class="big" id="top">Hello</h1> (a) #big (b) .red (c) #intro (d) #top -
38.🎯 Which CSS selector matches this element?
<h1 class="box" id="logo">Hello</h1> (a) h2 (b) .logo (c) #logo (d) #end - 39.True or false: .card is an element selector. (a) False (b) True
- 40.True or false: .card is an id selector. (a) True (b) False
Answer key
- an element selector
- p
- 1
- Yes
- .box
- li
- <h2 class="note">
- an id selector
- #
- <h1 class="note">
- .box
- #main
- False
- False
- False
- True
- <h1 class="note">
- #top
- True
- p
- p
- .
- #hero
- True
- <p class="note">
- True
- .box
- h1
- .box
- True
- #logo
- <div class="note">
- <p class="box">
- True
- an id selector
- .note
- #top
- #logo
- False
- False
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids