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