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