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