Take the 2-minute tour ×
Graphic Design Stack Exchange is a question and answer site for Graphic Design professionals, students, and enthusiasts. It's 100% free, no registration required.

I have 2 blocks of text that are pretty small (just under a paragraph each) and they really look better justified but the problem is that text-align: justify; sometimes adds really large spaces and makes the text somewhat ugly (the opposite effect, obviously).

Is it possible to more finely tune the word spacing with CSS so that this doesn't happen?

share|improve this question

2 Answers 2

up vote 7 down vote accepted

CSS TEXT-JUSTIFY

This property appears to offer a refinement on the “justify” value used in the ‘text-align’ property. Indeed, the “justify” value must be set for that property for ‘text-justify’ to have any effect.

Text-justify offers a fine level of justification control over the enclosed content, allowing for a variety of sophisticated justification models used in different language writing systems.

Example

<p style="text-align: justify; text-justify: newspaper;">
    This is “Newspaper” justified content
</p>

Possible Values

VALUE                   DESCRIPTION
----------------------  ---------------------------------------------------------------------
auto                    The browser will determine the appropriate justification algorithm to use
distribute              Justification is handled similarly to the “newspaper” value, but this version is optimized for East Asian content (especially the Thai language.) In this justification method, the last line is not justified.
distribute-all-lines    Behavior and intent for this value is the same as with the “distribute” value, but the last line is also justified.
inter-cluster           Justifies content that does not have any inter-word spacing (such as with many East Asian languages.)
inter-ideograph         Used for justifying blocks of ideographic content. Justification is achieved by increasing or decreasing spacing between ideographic characters and words as well.
inter-word              Justification is achieved by increasing the spacing between words. It is the quickest method of justification and does not justify the last line of a content block.
newspaper               Spacing between letters and words are increased or decreased as necessary. 

The IE reference says “it is the most sophisticated form of justification for Latin alphabets.”

Source: http://www.css3.com/css-text-justify/

Hope this helps!

share|improve this answer

In addition to using text-justify, which seems to be currently supported by IE only, consider adding hyphenation, with explicit hyphenation hints &shy; and/or browser-based automatic hyphenation, using hyphens: auto with due browser prefixes or using JavaScript-based hyphenator like Hyphenator.js. Hyphenation often greatly reduces the need for added spacing in justification.

share|improve this answer
    
The text-justify property is supported in all of the major browsers., source: w3schools.com/cssref/css3_pr_text-justify.asp and Text-Align, w3schools.com/cssref/pr_text_text-align.asp –  Ken Fyrstenberg Nov 2 '12 at 9:28
2  
@AbdiasSoftware, the page is bogus – yet another proof of w3schools being crap, see w3fools.com (The w3schools page contains “PlayIt” buttons, which you can use to see rather quickly that their info is wrong.) –  Jukka K. Korpela Nov 2 '12 at 9:35
    
They are a little outdated sometimes, but I wouldn't call them bogus :-) Here is anyways another source: reference.sitepoint.com/css/text-align –  Ken Fyrstenberg Nov 2 '12 at 9:50
    
@AbdiasSoftware, the other source is about another property. The reference.sitepoint.com site does not mention text-justify at all. But I’m sorry that I initially wrote about text-align-justify instead of text-justify (fixed now). The setting text-align: justify is of course implied here; the issue is whether the type of justification can be controlled. –  Jukka K. Korpela Nov 2 '12 at 9:54
    
Hm, well interesting. I will do some more research. Thanks. It's 4am here, my judgement is off :-) –  Ken Fyrstenberg Nov 2 '12 at 9:56

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.