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