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