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