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