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