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