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