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