Skip to content
easeweb
Search topics

Justified text with uneven gaps between words

A shop's journal sets its articles flush to both edges, so the browser stretches the spaces between words into uneven gaps, widest on a phone.

WCAG 2.2
SC 1.4.8AAA
Required by
Not required by Section 508 or EN 301 549
Broken text-align: justify
The accessibility problem illustrated: Cognitive:Why are there holes in the text?
01

The problem

People with dyslexia and other reading difficulties struggle to follow an article whose words are pulled apart by uneven gaps

02

Try it

Read the article as a phone shows it, then apply each fix and read it again

Look at the spaces between the words on each line, and at the wide ones lining up down the paragraph. Then apply each fix; with the second, tick Left-align text above the article.

Broken Can you fix this?

BrokenAn article set flush to both edges

Why every mug is a little different

Each mug starts as a lump of stoneware clay, thrown by hand on the wheel, so no two come out quite the same height. We trim the foot once the clay is leather-hard, then leave the mugs to dry slowly under plastic for about a week.

A recreated demo. The broken version is intentionally inaccessible.

03

The fix

Keep the spaces between words even

Before
BrokenAn article set flush to both edges
<article class="article">  <h1>Why every mug is a little different</h1>  <div class="article-body">    <p>Each mug starts as a lump of stoneware clay, thrown by hand on the wheel …</p>    <p>Glazing is where the differences really show. …</p>    …  </div></article>
What is wrong3 points
  • Every line but the last in each paragraph is stretched to reach both edges, so the spaces between words are a different width on every line.
  • On a phone each line holds a few words, and some gaps grow as wide as a short word.
  • Nothing on the page turns the justification off.
After

Text aligned to the start

<article class="article">  <h1>Why every mug is a little different</h1>  <div class="article-body">    <p>Each mug starts as a lump of stoneware clay, thrown by hand on the wheel …</p>    <p>Glazing is where the differences really show. …</p>    …  </div></article>
How it is fixed1 step
  1. Change text-align: justify to text-align: start. Every space between words is the font's own width again, on every line and at every screen width, and the right edge of each paragraph is ragged.

This fixes the Before and passes 1.4.8: with the column, spacing and colours it already had, the article meets all five parts on the page itself. The look keeps its column, type and spacing; only the straight right edge goes. start follows the direction of the text, so the same rule aligns a right-to-left language such as Arabic to the right, which C19 allows too.

04

Design ideas

A calm page doesn’t need two straight edges

Two more ways to set the same article, and the print look a designer might reach for instead. Try the colour swatches: the text stays ragged-right in all three.

In the design file

  • Set body text flush left with a ragged right edge, at every screen width.
  • Draw the article at phone width with its real copy, not placeholder text.
  • Write the line height beside the body style, at least 1.5 times the text size, and space paragraphs at least 1.5 times the line spacing apart.
  • Keep a line of body text to at most 80 characters, or 40 in Chinese, Japanese or Korean.

Passes

  • Glazing is where the differences really show. Our speckled oatmeal glaze breaks over the rims and handles, turning darker wherever it runs thin.

    In the kiln, the iron in the clay bleeds through as small brown freckles.

    Large type, open spacing 20px type, a line height of 1.7 and a full line’s space between paragraphs, in a column of about 65 characters a line. It is the calm, bookish page a straight edge is often reaching for, kept ragged-right.
  • Glazing is where the differences really show. Our speckled oatmeal glaze breaks over the rims and handles, turning darker wherever it runs thin.

    In the kiln, the iron in the clay bleeds through as small brown freckles.

    Page colours to choose from Three swatches above the text set its colour and the page’s together: paper 14.13:1, sepia 10.32:1 and night 13.16:1. A reader who reads better in one of these pairs switches to it without a browser setting.

Fails

  • Glazing is where the differences really show. Our speckled oatmeal glaze breaks over the rims and handles, turning darker wherever it runs thin.

    In the kiln, the iron in the clay bleeds through as small brown freckles.

    Justified, with hyphenationWCAG 1.4.8 The look of a printed book: long words are split with a hyphen at the line end, so the widest gaps close up. Every line is still stretched to both edges, so the spaces still change from line to line.
05

Verify the fix

4 checks, no mouse.

Test with: Text layout check, Keyboard

0 of 4 checked

Record the OS, browser and assistive-technology versions, the build, the date, and the actual result of each step. Repeat whenever the theme, the article template or the custom CSS changes.

Limits

This is a starting pattern, not a guarantee for every application. 1.4.8 is Level AAA, above the AA level that most policies ask for, but this part of it costs one word of CSS. The guide covers the justification part only; the example meets the other four by its line height, column width, colours and relative sizes. Class names in the snippets are placeholders, and no particular reading mode or browser setting is claimed to meet the criterion.

This is a recreated teaching example, not a finding about a named client. The code is a starting pattern: test it in your own product. No completed assistive-technology test is claimed here.

EaseWeb service

Fixed it? Keep it from coming back.

I turn guides like this one into rules your coding agents follow and checks your CI runs. Then I retest by hand with a keyboard and screen readers, periodically.

See the service