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