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