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