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