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