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