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