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