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