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