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