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