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