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