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