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