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