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