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