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