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