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