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