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