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