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