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