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