Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should I avoid using "text-align: justify;"?

Is there any reason to avoid using text-align: justify;?

Does it reduce readability or cause problems?

like image 735
Gabe Sumner Avatar asked Nov 24 '08 23:11

Gabe Sumner


People also ask

Why You Should not justify text?

Justifying text disrupts that even texture. Even if a page layout program is using subtle letter-spacing, or adjusting the width of the letters – these things, too, will make the texture uneven. So, justified text should really be avoided not just on the web, but whenever possible.

Is Justified text bad for accessibility?

Justified text can produce readability issues for people with dyslexia and other conditions that affect reading and comprehension. Justified text can produce unevenly enlarged spaces between certain words, sometimes known as "rivers".

Does justified text look better?

Compared to left-aligned text, justification gives text a cleaner, more formal look. Justification works by adding white space between the words in each line so all the lines are the same length. This alters the ideal spacing of the font, but in paragraphs of reasonable width it's usually not distracting.


2 Answers

Firstly, this is purely a design-related problem and solution. The design of your grid specifies if justifying text is needed. I think justify align alone has no major effect on usability. Bad typography that makes text illegible is what decreases usability. That said, make sure you have solid contrasts and a good balance of spacing in your type. Font-size matters too.

This site is a successful attempt at justifying text online. Since you can't control the spaces between letters and words nearly as much with CSS as you can with InDesign, it's a lot harder to justify text and not have 'rivers' of whitespace run down your rows, which happens when the spaces between words exceeds the spaces between lines. Things that make justifying text difficult: long words, row widths that don't hold enough words, and too much contrast between the text and the background colors; they make the rivers appear wider and more apparent.

The typographic ideal is to have an even text-block, where if you squint the text block becomes a uniform solid shade. So if you keep text at about 10px and 60% gray on white background, and have rows that fit about 20 words, justify align shouldn't look ugly. But keep in mind this does nothing to improve usability. Small, relatively light text annoys a lot of people, especially the older readers.

I should note that with ­ (soft hyphenation) correctly separating long troublesome words like super­awesome you can mimic proper typesetting (e.g. InDesign). There's a lot of stuff out there to help you do this. I would recommend the logic for hiding, manipulating, and displaying the text to be done on the client side, perhaps with this.

Edit: As others mention below, css hyphens are possible now, except not feasible (not in Chrome). Plus, css4 offers even more control.

like image 171
hlfcoding Avatar answered Sep 19 '22 14:09

hlfcoding


text-align: justify shouldn't be used in browsers at the moment. They aren't good at handling the minute details within and the output ends up containing lots of rivers and there's no support for hyphenation (other than soft hyphens).

Note above was written 4.5 years ago. Things are slowly changing... http://caniuse.com/#feat=css-hyphens

Edit: Hyphenator was brought to my attention in this answer's comments. It looks like it makes text-align justify worth using, check out the sites that use it. You may want to use javascript to apply text-align justify before using this script so that those without javascript don't get caught out.

Edit 2: CSS now allows for hyphenation with the hyphens property [browser support]. PPK is now saying to add it to your stylesheets, whilst Eric Meyer says just add it for mobile.

Edit 3: A good little overview of things available to us now, with some SASS.

like image 25
dylanfm Avatar answered Sep 23 '22 14:09

dylanfm