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