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