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