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