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