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