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