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