CSS Worksheet: Which Rule Wins
Code tip (Stronger first, then later): Strength: #id > .class > element. The stronger selector wins, wherever it is written. Equal strength: the later rule wins.
NameDateTime takenScore ___ / 40
- 1.⚖️ Which selector is the weakest? (a) an element selector (b) an id selector (c) a class selector
-
2.⚖️ What colour is the text of this element?
<h2 class="box" id="hero">Hi</h2>
CSS:
h2 { color: green; }
h2 { color: purple; } (a) purple (b) white (c) blue (d) green -
3.⚖️ What colour is the text of this element?
<p class="note" id="intro">Hi</p>
CSS:
p { color: red; }
p { color: green; } (a) orange (b) purple (c) green (d) red -
4.⚖️ What colour is the text of this element?
<h2 class="star" id="intro">Hi</h2>
CSS:
h2 { color: green; }
h2 { color: white; } (a) orange (b) green (c) purple (d) white -
5.⚖️ What colour is the text of this element?
<h1 class="red" id="end">Hi</h1>
CSS:
h1 { color: purple; }
h1 { color: white; } (a) orange (b) white (c) black (d) purple -
6.⚖️ What colour is the text of this element?
<h1 class="star" id="logo">Hi</h1>
CSS:
#logo { color: black; }
h1 { color: purple; }
.star { color: blue; } (a) blue (b) red (c) purple (d) black -
7.⚖️ What colour is the text of this element?
<h2 class="note" id="hero">Hi</h2>
CSS:
.note { color: green; }
#hero { color: red; }
h2 { color: purple; } (a) red (b) green (c) white (d) purple -
8.⚖️ What colour is the text of this element?
<p class="menu" id="top">Hi</p>
CSS:
.menu { color: orange; }
#top { color: green; }
p { color: red; } (a) orange (b) green (c) red (d) white -
9.⚖️ What colour is the text of this element?
<h2 class="note" id="main">Hi</h2>
CSS:
h2 { color: blue; }
h2 { color: orange; } (a) red (b) blue (c) purple (d) orange - 10.⚖️ Two rules with the same selector set a colour. Which one wins? (a) the later one (b) the first one (c) the shorter one (d) neither
-
11.⚖️ What colour is the text of this element?
<p class="box" id="top">Hi</p>
CSS:
#top { color: green; }
#top { color: purple; } (a) red (b) purple (c) white (d) green -
12.⚖️ What colour is the text of this element?
<p class="red" id="intro">Hi</p>
CSS:
p { color: orange; }
#intro { color: purple; } (a) red (b) purple (c) black (d) orange -
13.⚖️ What colour is the text of this element?
<h1 class="big" id="intro">Hi</h1>
CSS:
#intro { color: purple; }
h1 { color: yellow; }
.big { color: blue; } (a) black (b) purple (c) blue (d) yellow -
14.⚖️ What colour is the text of this element?
<p class="box" id="logo">Hi</p>
CSS:
.box { color: orange; }
.box { color: purple; } (a) orange (b) red (c) purple (d) green -
15.⚖️ What colour is the text of this element?
<h2 class="menu" id="main">Hi</h2>
CSS:
.menu { color: green; }
.menu { color: purple; } (a) purple (b) blue (c) green (d) black -
16.⚖️ What colour is the text of this element?
<h1 class="menu" id="main">Hi</h1>
CSS:
.menu { color: red; }
h1 { color: white; }
#main { color: black; } (a) white (b) red (c) green (d) black - 17.⚖️ Which selector is the strongest? (a) a class selector (b) an id selector (c) an element selector
-
18.⚖️ What colour is the text of this element?
<h2 class="menu" id="main">Hi</h2>
CSS:
h2 { color: green; }
.menu { color: red; } (a) blue (b) green (c) black (d) red -
19.⚖️ What colour is the text of this element?
<h1 class="menu" id="intro">Hi</h1>
CSS:
.menu { color: orange; }
.menu { color: red; } (a) purple (b) orange (c) red (d) green -
20.⚖️ What colour is the text of this element?
<p class="note" id="main">Hi</p>
CSS:
.note { color: blue; }
.note { color: green; } (a) yellow (b) green (c) orange (d) blue -
21.⚖️ What colour is the text of this element?
<h1 class="big" id="intro">Hi</h1>
CSS:
.big { color: yellow; }
#intro { color: green; } (a) red (b) black (c) green (d) yellow -
22.⚖️ What colour is the text of this element?
<p class="star" id="hero">Hi</p>
CSS:
p { color: green; }
p { color: yellow; } (a) black (b) green (c) purple (d) yellow -
23.⚖️ What colour is the text of this element?
<h1 class="note" id="main">Hi</h1>
CSS:
h1 { color: red; }
h1 { color: green; } (a) yellow (b) red (c) green (d) black -
24.⚖️ What colour is the text of this element?
<h1 class="box" id="top">Hi</h1>
CSS:
h1 { color: orange; }
#top { color: yellow; }
.box { color: black; } (a) orange (b) yellow (c) purple (d) black -
25.⚖️ What colour is the text of this element?
<h1 class="box" id="logo">Hi</h1>
CSS:
#logo { color: green; }
h1 { color: yellow; } (a) yellow (b) purple (c) red (d) green -
26.⚖️ What colour is the text of this element?
<h2 class="red" id="end">Hi</h2>
CSS:
#end { color: red; }
.red { color: white; }
h2 { color: green; } (a) green (b) white (c) blue (d) red -
27.⚖️ What colour is the text of this element?
<h1 class="big" id="intro">Hi</h1>
CSS:
h1 { color: black; }
h1 { color: red; } (a) blue (b) black (c) green (d) red -
28.⚖️ What colour is the text of this element?
<h2 class="note" id="logo">Hi</h2>
CSS:
#logo { color: black; }
h2 { color: orange; } (a) orange (b) green (c) white (d) black -
29.⚖️ What colour is the text of this element?
<h2 class="big" id="hero">Hi</h2>
CSS:
#hero { color: red; }
#hero { color: white; } (a) black (b) red (c) yellow (d) white -
30.⚖️ What colour is the text of this element?
<h1 class="menu" id="intro">Hi</h1>
CSS:
.menu { color: red; }
.menu { color: green; } (a) red (b) orange (c) green (d) purple -
31.⚖️ What colour is the text of this element?
<h1 class="menu" id="end">Hi</h1>
CSS:
h1 { color: white; }
#end { color: purple; } (a) purple (b) white (c) yellow (d) blue -
32.⚖️ What colour is the text of this element?
<h2 class="menu" id="hero">Hi</h2>
CSS:
h2 { color: yellow; }
h2 { color: orange; } (a) yellow (b) blue (c) orange (d) white -
33.⚖️ What colour is the text of this element?
<h1 class="star" id="top">Hi</h1>
CSS:
.star { color: purple; }
h1 { color: blue; } (a) blue (b) purple (c) red (d) green -
34.⚖️ What colour is the text of this element?
<h2 class="red" id="top">Hi</h2>
CSS:
.red { color: orange; }
h2 { color: yellow; } (a) yellow (b) orange (c) green (d) purple -
35.⚖️ What colour is the text of this element?
<p class="big" id="intro">Hi</p>
CSS:
#intro { color: purple; }
#intro { color: yellow; } (a) green (b) yellow (c) orange (d) purple -
36.⚖️ What colour is the text of this element?
<p class="note" id="logo">Hi</p>
CSS:
p { color: purple; }
#logo { color: blue; }
.note { color: green; } (a) green (b) red (c) blue (d) purple -
37.⚖️ What colour is the text of this element?
<h1 class="box" id="logo">Hi</h1>
CSS:
h1 { color: black; }
#logo { color: blue; } (a) white (b) green (c) blue (d) black -
38.⚖️ What colour is the text of this element?
<h1 class="box" id="top">Hi</h1>
CSS:
.box { color: blue; }
h1 { color: orange; }
#top { color: white; } (a) black (b) orange (c) blue (d) white -
39.⚖️ What colour is the text of this element?
<h1 class="box" id="end">Hi</h1>
CSS:
#end { color: red; }
#end { color: blue; } (a) red (b) purple (c) black (d) blue -
40.⚖️ What colour is the text of this element?
<h1 class="star" id="end">Hi</h1>
CSS:
#end { color: green; }
#end { color: red; } (a) red (b) purple (c) green (d) blue
Answer key
- an element selector
- purple
- green
- white
- white
- black
- red
- green
- orange
- the later one
- purple
- purple
- purple
- purple
- purple
- black
- an id selector
- red
- red
- green
- green
- yellow
- green
- yellow
- green
- red
- red
- black
- white
- green
- purple
- orange
- purple
- orange
- yellow
- blue
- blue
- white
- blue
- red
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids