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