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