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