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