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