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