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