The text-align property

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

The text-align property

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. Which CSS rule centres the text inside an h1 heading?
A h1 { text-align: centre; }
B h1 { text-align: center; }
2. What does text-align style?
A The lines of text inside the element
B The position of the element's box on the page
3. Which value pushes the text to the right-hand edge of its element?
A text-align: right;
B text-align: end-of-line;
4. Which line is written with correct CSS syntax?
A p { text-align = left; }
B p { text-align: left; }
5. Which property would you use to centre the words of a heading?
A text-align
B font-align

Match the Pairs

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

Left columnRight column
1h1 { text-align: center; } Atext-align: left;
2p { text-align: right; } BLines up the text of every paragraph against the right edge
3Left alignment lines the text up against the left edge of its element CA colon is needed between the property and its value, not an equals sign.
4text-align styles the text inside an element, so it is written in the rule for that element Dh2 { text-align: center; }
5h1 { text-align: centre; } ECSS uses the American spelling center. The value centre is not valid, so the heading stays aligned left.
6h1 { text-align = center; } FCentres the text of every h1 heading in the middle of its line

Definitions

text-align

Fill in the Blanks

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

1.
h1 { __________: center; }
2.
h1 { text-align: ______; }
3.
p { text-align: ____; }
4.
__ { text-align: right; }
5.
.date { text-align: _____; }

Spot the Error

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

Question 1
A h1 {
B color: navy;
C font-size: 32px;
D text-align: centre;
E }
Question 2
A p {
B color: black;
C font-size: 16px;
D text-align right;
E }
Question 3
A h2 {
B color: teal;
C text-align: middle;
D }
Question 4
A h1 (
B text-align: center;
C color: purple;
D }
Question 5
A p.note {
B text_align: right;
C color: gray;
D }

Answer Key

The text-align property
Section A: Quick Questions
Q1
B — h1 { text-align: center; }
Q2
A — The lines of text inside the element
Q3
A — text-align: right;
Q4
B — p { text-align: left; }
Q5
A — text-align
Section B: Match the Pairs
Q1
h1 { text-align: center; } → Centres the text of every h1 heading in the middle of its line
Q2
p { text-align: right; } → Lines up the text of every paragraph against the right edge
Q3
Left alignment lines the text up against the left edge of its element → text-align: left;
Q4
text-align styles the text inside an element, so it is written in the rule for that element → h2 { text-align: center; }
Q5
h1 { text-align: centre; } → CSS uses the American spelling center. The value centre is not valid, so the heading stays aligned left.
Q6
h1 { text-align = center; } → A colon is needed between the property and its value, not an equals sign.
Section C: Definitions
Q1
text-align — A CSS property that sets how lines of text line up inside an element: left, center or right. Example: text-align: center; centres a heading's text. It styles the text, not the box.
Section D: Fill in the Blanks
Q1
h1 { text-align: center; }
Q2
h1 { text-align: center; }
Q3
p { text-align: left; }
Q4
h2 { text-align: right; }
Q5
.date { text-align: right; }
Section E: Spot the Error
Q1
D — CSS only accepts the American spelling 'center' as a text-align value. 'centre' is ignored, so the heading stays left-aligned. It should be text-align: center;
Q2
D — A CSS declaration needs a colon between the property and its value. It should be text-align: right;
Q3
C — 'middle' is not a valid text-align value. The valid values are left, right, center and justify. For the middle of the line use text-align: center;
Q4
A — A CSS rule's declarations go inside curly braces { }, not round brackets. The first line should be h1 {
Q5
B — The CSS property name uses a hyphen, not an underscore. It should be text-align: right;