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