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