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