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