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