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