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