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