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