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