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