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