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