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