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