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