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