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