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