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