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