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