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