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