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