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