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