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