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