Text styling

Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.

This Text styling worksheet is part of the HTML and CSS Journey journey. Print it as a booklet?

Text styling

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. Which declaration centres text inside its container?
A text-align: center;
B align-text: middle;
2. Which declaration removes the underline from a link?
A text-underline: off;
B text-decoration: none;
3. What does text-transform: uppercase do?
A Rewrites the words in the HTML as capitals
B Shows the letters as capitals without changing the HTML
4. What does line-height control?
A The space between lines of text
B The height of each letter
5. Which property sets the colour of the text itself?
A color
B text-color

Match the Pairs

Draw a line connecting each item on the left to its match on the right.

Left columnRight column
1text-align: center; ADraws a line under the text
2text-decoration: underline; BCentres the text inside its container
3text-transform: capitalize; Cmiddle is not a valid value, so it should be center
4The space between lines of text DMisspelt property: CSS uses color, not colour
5text-align: middle; EMakes the first letter of every word a capital
6text-colour: red; Fline-height: 1.5;

Definitions

text-align

Fill in the Blanks

Complete each line of code by filling in the missing parts.

1.
p { text-align: ______; }
2.
a { text-decoration: ____; }
3.
h2 { ______________: uppercase; }
4.
p { ___________: 1.5; }
5.
h1 { letter-spacing: ___; }

Spot the Error

Shade in the letter of the line that contains an error.

Question 1
A p {
B text-align: middle;
C }
Question 2
A a {
B text-decoration: no;
C }
Question 3
A h1 {
B text-transform: uppercase
C color: navy;
D }
Question 4
A p {
B line height: 1.6;
C }
Question 5
A h2 {
B text-colour: red;
C }

Answer Key

Text styling
Section A: Quick Questions
Q1
A — text-align: center;
Q2
B — text-decoration: none;
Q3
B — Shows the letters as capitals without changing the HTML
Q4
A — The space between lines of text
Q5
A — color
Section B: Match the Pairs
Q1
text-align: center; → Centres the text inside its container
Q2
text-decoration: underline; → Draws a line under the text
Q3
text-transform: capitalize; → Makes the first letter of every word a capital
Q4
The space between lines of text → line-height: 1.5;
Q5
text-align: middle; → middle is not a valid value, so it should be center
Q6
text-colour: red; → Misspelt property: CSS uses color, not colour
Section C: Definitions
Q1
text-align — A CSS property that sets how lines of text line up inside their container: left, right, center or justify.
Section D: Fill in the Blanks
Q1
p { text-align: center; }
Q2
a { text-decoration: none; }
Q3
h2 { text-transform: uppercase; }
Q4
p { line-height: 1.5; }
Q5
h1 { letter-spacing: 2px; }
Section E: Spot the Error
Q1
B — middle is not a text-align value. It should be text-align: center; to put the text in the middle.
Q2
B — no is not a valid value. It should be text-decoration: none; to remove the underline.
Q3
B — The text-transform declaration has no semicolon. It should be text-transform: uppercase; before the next declaration.
Q4
B — The property name has a space instead of a hyphen. It should be line-height: 1.6; written as one hyphenated word.
Q5
B — text-colour is not a CSS property. Text colour is set with color: red; using US spelling.