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