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