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