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