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