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