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