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