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