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