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