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