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