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