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