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