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