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