CSS text-justify Property

The CSS text-justify property specifies how spacing is adjusted between words or characters when text is justified.

It works with text-align: justify to control how the browser distributes additional space across a line. Different justification methods can improve the appearance of text depending on its language, writing system, and available width.

The property does not enable justification by itself. It determines the justification method used when the text is already set to justified alignment.

text-justify Syntax

The text-justify property accepts one keyword that determines how the browser adjusts spacing within justified lines.

Basic Syntax

p {
  text-align: justify;
  text-justify: inter-word;
}

Available Values

.example {
  text-justify: auto;
}
.example {
  text-justify: inter-word;
}
.example {
  text-justify: inter-character;
}
.example {
  text-justify: none;
}

CSS-Wide Keywords

.example {
  text-justify: initial;
}
.example {
  text-justify: inherit;
}
.example {
  text-justify: unset;
}
.example {
  text-justify: revert;
}
.example {
  text-justify: revert-layer;
}

The initial value is auto. Because the property is inherited, unset behaves like inherit.

Valid Examples

.article {
  text-align: justify;
  text-justify: auto;
}
.article {
  text-align: justify;
  text-justify: inter-word;
}
.article {
  text-align: justify;
  text-justify: inter-character;
}
.article {
  text-align: justify;
  text-justify: none;
}

Invalid Examples

.example {
  text-justify: center;
}
.example {
  text-justify: distribute;
}
.example {
  text-justify: 20px;
}
.example {
  text-justify: inter-word inter-character;
}

The standard property does not accept alignment keywords, lengths, multiple justification methods, or the legacy distribute value.

Property Values

Value Description
auto Allows the browser to select an appropriate justification method based on the text and writing system.
inter-word Adjusts spacing primarily between words to justify text.
inter-character Adjusts spacing between characters to justify text.
none Disables justification spacing adjustments, even when justified alignment is requested.

Property Characteristics

Characteristic Value
Initial value auto
Inherited Yes
Applies to Block containers
Computed value Specified keyword
Animation type Discrete
Percentages Not applicable
Lengths Not accepted
Specification CSS Text Module Level 3

Note: Browser support differs between the individual values. The auto value is the safest general-purpose choice when a particular spacing method is not required.

How It Works

Justified text attempts to align the edges of eligible lines with both sides of the available inline text area.

Step 1: Enable Justified Alignment

.article-text {
  text-align: justify;
}

The browser distributes available space across eligible lines using its default justification method.

Step 2: Select a Justification Method

.article-text {
  text-align: justify;
  text-justify: inter-word;
}

The browser uses spacing between words as the primary justification opportunity.

Step 3: Try Character Spacing

.article-text {
  text-align: justify;
  text-justify: inter-character;
}

The browser uses spacing opportunities between characters, where supported and appropriate.

Step 4: Return to Automatic Selection

.article-text {
  text-align: justify;
  text-justify: auto;
}

The browser chooses the justification method.

Important Consideration

Actual spacing depends on the available line width, language, font, and browser's text layout implementation. A line with little or no extra space may show no obvious difference between methods.

The auto Value

The auto value lets the browser determine an appropriate method for distributing space in justified text.

Basic Example

p {
  text-align: justify;
  text-justify: auto;
}

Default Behavior

Because auto is the initial value, it does not need to be declared when the browser's default justification method is acceptable.

p {
  text-align: justify;
}

Multilingual Content

.multilingual-text {
  text-align: justify;
  text-justify: auto;
}

Automatic selection allows the browser to use language-appropriate justification behavior.

When to Use auto

Use auto for general article text, multilingual content, and layouts where the browser should determine the spacing method.

The inter-word Value

The inter-word value distributes additional space primarily between words.

Basic Example

.article-text {
  text-align: justify;
  text-justify: inter-word;
}

How Word Spacing Changes

When a line contains extra space, the browser expands appropriate word-spacing opportunities so the line reaches the justified edge.

Article Paragraphs

article p {
  text-align: justify;
  text-justify: inter-word;
  line-height: 1.7;
}

This approach is commonly suitable for languages such as English that use spaces to separate words.

Narrow Containers

In narrow columns, inter-word justification may create large gaps between words when few spacing opportunities are available.

Using Hyphenation

article p {
  text-align: justify;
  text-justify: inter-word;
  hyphens: auto;
}

Automatic hyphenation can reduce uneven word spacing in supported languages and browsers. Set an appropriate HTML lang attribute for the text.

Important Consideration

Word spacing is not guaranteed to be identical across all justified lines. The browser adjusts spacing according to the available width and its layout rules.

The inter-character Value

The inter-character value distributes additional space between characters instead of relying primarily on spaces between words.

Basic Example

.character-justified {
  text-align: justify;
  text-justify: inter-character;
}

East Asian Typography

.japanese-text {
  text-align: justify;
  text-justify: inter-character;
}

Character-based justification can be useful for writing systems where characters are commonly arranged without spaces between words.

HTML Example

<p class="japanese-text" lang="ja">
  ウェブデザインでは、文字の配置や行間の調整が読みやすさに影響します。
</p>

Character Spacing vs. letter-spacing

.example {
  letter-spacing: 2px;
}

The letter-spacing property adds spacing independently of justification. In contrast, text-justify: inter-character adjusts spacing opportunities to fill eligible justified lines.

Browser Differences

Support for inter-character is less consistent than automatic justification. Test the value in the browsers required by your project.

Important Consideration

Character-based justification does not mean the browser can insert space inside every typographic character or joined glyph. Text shaping and language rules still influence spacing opportunities.

The none Value

The none value disables additional justification spacing adjustments.

Basic Example

.example {
  text-align: justify;
  text-justify: none;
}

Although justified alignment is requested, the browser does not expand spacing to justify the text.

Comparing none and auto

.normal-justification {
  text-align: justify;
  text-justify: auto;
}
.no-justification {
  text-align: justify;
  text-justify: none;
}

When to Use none

Use none when you need to prevent spacing expansion while retaining a separately specified alignment rule.

Important Consideration

The value does not change text-align itself. It controls whether the justification spacing adjustments are applied.

Working With text-align

The text-justify property works with text alignment. It does not independently activate justified text.

Justified Text

.example {
  text-align: justify;
  text-justify: inter-word;
}

Left-Aligned Text

.example {
  text-align: left;
  text-justify: inter-word;
}

Because the text is not justified, the text-justify setting normally has no visible effect.

Right-Aligned Text

.example {
  text-align: right;
  text-justify: inter-character;
}

The justification method does not override the right alignment.

Centered Text

.example {
  text-align: center;
  text-justify: auto;
}

Centered text does not use justification spacing.

Using Logical Alignment

.example {
  text-align: start;
}

The start value aligns text to the inline-start side of its writing direction rather than justifying it.

Comparison

Property Purpose
text-align Determines how inline content is aligned within its line box.
text-justify Determines which spacing method is used when text is justified.
text-align-last Controls alignment of the last line and lines immediately before forced line breaks.

Language Considerations

Justification methods can produce different results depending on the language and writing system.

Languages With Word Spaces

.english-text {
  text-align: justify;
  text-justify: inter-word;
}

Word-based justification is often appropriate for English and other languages that commonly separate words with spaces.

East Asian Text

.east-asian-text {
  text-align: justify;
  text-justify: inter-character;
}

Character-based spacing can be appropriate for some East Asian text layouts.

Automatic Language-Aware Justification

.multilingual-content {
  text-align: justify;
  text-justify: auto;
}

Automatic justification is often preferable when content includes multiple writing systems.

HTML Language Attributes

<p lang="en">English paragraph text.</p>
<p lang="ja">日本語の文章です。</p>

Language attributes help browsers apply appropriate text layout, line-breaking, and hyphenation behavior.

Right-to-Left Languages

<p lang="ar" dir="rtl" class="justified-text">
  هذا نص عربي يوضح محاذاة النص وضبط المسافات.
</p>
.justified-text {
  text-align: justify;
  text-justify: auto;
}

The browser applies justification according to its support for the language and writing system.

Important Consideration

Not every writing system uses the same spacing opportunities. A justification method that works well for one language may produce poor results for another.

Line Breaks and Last Lines

Justification normally affects eligible lines that wrap before the end of a paragraph. The final line typically retains its normal alignment unless another property changes that behavior.

Standard Justification

p {
  text-align: justify;
  text-justify: inter-word;
}

Most wrapped lines are justified, while the final line normally remains aligned to the start.

Justifying the Last Line

p {
  text-align: justify;
  text-align-last: justify;
  text-justify: inter-word;
}

The browser also attempts to justify the last line.

Forced Line Breaks

<p class="example">
  This is the first part of the text.<br>
  This is the second part of the text.
</p>

Lines immediately before forced breaks are treated as last lines for alignment purposes.

Hyphenation

p {
  text-align: justify;
  text-justify: auto;
  hyphens: auto;
}

Hyphenation can create additional line-breaking opportunities and reduce uneven spacing.

Important Consideration

Short lines may have too few spacing opportunities to produce visually balanced justification. Avoid forcing justification on every line without checking readability.

Inheritance

The text-justify property is inherited. Descendant block containers can use the justification method specified by their parent.

Inherited Justification Method

.article-content {
  text-align: justify;
  text-justify: inter-word;
}

Paragraphs within the container can inherit the alignment and justification method.

Overriding the Method

.article-content {
  text-justify: inter-word;
}
.article-content .special-text {
  text-justify: inter-character;
}

Explicit Inheritance

.child {
  text-justify: inherit;
}

Restoring the Initial Value

.child {
  text-justify: initial;
}

This restores auto.

Using unset

.child {
  text-justify: unset;
}

Because the property is inherited, unset uses the parent's computed value.

Important Consideration

Inheritance does not automatically justify text. The text must also have an appropriate text-align value.

Practical Examples

Automatic Justification

.article-text {
  text-align: justify;
  text-justify: auto;
}

Word-Based Justification

.article-text {
  text-align: justify;
  text-justify: inter-word;
}

Character-Based Justification

.japanese-text {
  text-align: justify;
  text-justify: inter-character;
}

Disabling Justification Adjustments

.no-spacing-adjustment {
  text-align: justify;
  text-justify: none;
}

Justification With Hyphenation

.reading-content {
  text-align: justify;
  text-justify: auto;
  hyphens: auto;
}

Justifying the Last Line

.fully-justified {
  text-align: justify;
  text-align-last: justify;
  text-justify: inter-word;
}

Responsive Justification

.article-text {
  text-align: justify;
  text-justify: auto;
}
@media (max-width: 600px) {
  .article-text {
    text-align: start;
  }
}

This disables justified alignment on narrow screens, where uneven spacing can be more noticeable.

Feature Detection

.article-text {
  text-align: justify;
}
@supports (text-justify: inter-word) {
  .article-text {
    text-justify: inter-word;
  }
}

Browsers that do not recognize the requested value retain their default justification behavior.

text-justify Example

This example compares automatic, word-based, character-based, and disabled justification. The paragraphs use the same width and text to make spacing differences easier to identify.

HTML Example

<div class="text-justify-demo">
  <div class="justify-sample">
    <strong>auto</strong>
    <p class="justify-auto">CSS provides several ways to control how text is arranged within a paragraph. Justified alignment adjusts the spacing between words or characters to create more even text edges.</p>
  </div>
  <div class="justify-sample">
    <strong>inter-word</strong>
    <p class="justify-words">CSS provides several ways to control how text is arranged within a paragraph. Justified alignment adjusts the spacing between words or characters to create more even text edges.</p>
  </div>
  <div class="justify-sample">
    <strong>inter-character</strong>
    <p class="justify-characters">CSS provides several ways to control how text is arranged within a paragraph. Justified alignment adjusts the spacing between words or characters to create more even text edges.</p>
  </div>
  <div class="justify-sample">
    <strong>none</strong>
    <p class="justify-none">CSS provides several ways to control how text is arranged within a paragraph. Justified alignment adjusts the spacing between words or characters to create more even text edges.</p>
  </div>
</div>

CSS Example

.text-justify-demo {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}
.text-justify-demo .justify-sample {
  padding: 18px;
  border: 1px solid #cbd5e1;
  background: #f8fafc;
}
.text-justify-demo strong {
  display: block;
  margin-bottom: 12px;
  color: #334155;
  font-size: 14px;
}
.text-justify-demo p {
  margin: 0;
  color: #1f2937;
  font-size: 16px;
  line-height: 1.7;
  text-align: justify;
}
.text-justify-demo .justify-auto {
  text-justify: auto;
}
.text-justify-demo .justify-words {
  text-justify: inter-word;
}
.text-justify-demo .justify-characters {
  text-justify: inter-character;
}
.text-justify-demo .justify-none {
  text-justify: none;
}
Browser Result
auto

CSS provides several ways to control how text is arranged within a paragraph. Justified alignment adjusts the spacing between words or characters to create more even text edges.

inter-word

CSS provides several ways to control how text is arranged within a paragraph. Justified alignment adjusts the spacing between words or characters to create more even text edges.

inter-character

CSS provides several ways to control how text is arranged within a paragraph. Justified alignment adjusts the spacing between words or characters to create more even text edges.

none

CSS provides several ways to control how text is arranged within a paragraph. Justified alignment adjusts the spacing between words or characters to create more even text edges.

Comparing the Results

Value Expected Behavior
auto The browser chooses a justification method.
inter-word Extra space is distributed primarily between words.
inter-character Extra space is distributed between appropriate character boundaries.
none Additional justification spacing is disabled.

Note: Some samples may look similar or identical depending on browser support, font metrics, and the available line width.

Changing the Paragraph Width

.text-justify-demo .justify-sample {
  max-width: 300px;
}

Changing the available width alters line wrapping and may make justification differences more noticeable.

Adding Hyphenation

.text-justify-demo p {
  hyphens: auto;
}

Where supported, hyphenation may improve spacing by allowing words to break at appropriate positions. Language information should be supplied in the HTML.

Disabling Justified Alignment

.text-justify-demo p {
  text-align: start;
}

All samples return to normal start alignment, making their text-justify settings visually inactive.

Accessibility Considerations

Justified text can create uneven spacing that makes reading more difficult, particularly for users with certain visual or reading disabilities.

Avoid Large Word Gaps

Word-based justification can create distracting spaces when lines contain relatively few words.

Consider Start Alignment

For long-form content, start-aligned text is often easier to read than fully justified text.

Test Narrow Screens

Justification can produce larger spacing differences on small displays.

Support Text Resizing

Verify that spacing remains readable when users enlarge text or zoom the page.

Use Appropriate Language Attributes

Language information helps browsers select suitable line-breaking and justification behavior.

Use Hyphenation Carefully

Automatic hyphenation may reduce excessive spacing, but should be tested for the language and content.

Avoid Forced Character Spacing for All Languages

Character-based justification may be unsuitable for text that relies on joined glyphs or particular word-spacing conventions.

Maintain Comfortable Line Lengths

Use appropriate container widths and line heights to support readability.

Do Not Use Justification as a Substitute for Layout

Use CSS layout properties to position elements rather than forcing text spacing to create alignment.

Common Mistakes

Forgetting text-align: justify

p {
  text-justify: inter-word;
}

Without justified alignment, the property normally has no visible effect.

Correct Combination

p {
  text-align: justify;
  text-justify: inter-word;
}

Using Alignment Keywords

p {
  text-justify: center;
}

Use text-align: center for centered text.

Using Length Values

p {
  text-justify: 10px;
}

The property accepts keywords, not lengths.

Combining Multiple Methods

p {
  text-justify: inter-word inter-character;
}

Only one justification method can be specified.

Using Legacy Values

p {
  text-justify: distribute;
}

The legacy distribute value is not part of the standard syntax.

Expecting the Last Line to Be Justified

Use text-align-last when the final line needs a different alignment.

Expecting Identical Spacing in Every Browser

Justification algorithms and supported values can differ between browser engines.

Using inter-character Without Testing

Character-based justification may not be supported consistently in all target browsers.

Justifying Very Narrow Columns

Narrow containers can produce excessive spacing between words or characters.

Ignoring Language and Writing System

Different languages may require different spacing and line-breaking rules.

Important Considerations

Keep the following points in mind when using text-justify:

  • The property controls the method used to justify text.
  • It does not enable justified alignment by itself.
  • Use text-align: justify to request justified text.
  • The initial value is auto.
  • The property is inherited.
  • The standard values are auto, inter-word, inter-character, and none.
  • The auto value lets the browser select the justification method.
  • The inter-word value adjusts spacing primarily between words.
  • The inter-character value adjusts spacing between appropriate character boundaries.
  • The none value disables additional justification spacing.
  • Lengths and percentages are not accepted.
  • Only one justification method can be specified.
  • Legacy values such as distribute are not part of the standard syntax.
  • Browser support varies between the individual values.
  • Justification behavior depends on language and writing system.
  • Font metrics and available line width influence spacing.
  • Automatic line wrapping affects which lines are justified.
  • The final line is normally not justified unless its alignment is changed.
  • The text-align-last property controls last-line alignment.
  • Hyphenation can help reduce uneven word spacing.
  • Language attributes can improve text layout behavior.
  • Justified text can produce large gaps in narrow columns.
  • Character-based justification may not suit every writing system.
  • Start-aligned text is often preferable for readability.
  • Test justification at different viewport widths and text sizes.

Browser Support

The CSS text-justify property has limited availability across major browsers. Support for the property and its individual values is less consistent than support for text-align: justify.

Some browsers recognize only certain justification methods, while others may ignore the property and use their default justification algorithm.

For current compatibility information, visit Can I Use? and search for text-justify.

Widely Supported Fallback

.article-text {
  text-align: justify;
}

Basic justified alignment is widely supported even when the text-justify property is unavailable.

Adding a Preferred Method

.article-text {
  text-align: justify;
  text-justify: inter-word;
}

Browsers that support inter-word can use it. Other browsers retain their default justification behavior.

Feature Detection

@supports (text-justify: inter-character) {
  .article-text {
    text-justify: inter-character;
  }
}

This checks whether the browser recognizes the specified declaration. It does not guarantee identical visual results across browsers.

Responsive Fallback

.article-text {
  text-align: justify;
  text-justify: auto;
}
@media (max-width: 600px) {
  .article-text {
    text-align: start;
  }
}

This retains justified alignment on wider screens while using start alignment on narrower screens.

Testing Recommendations

Compare the results in Chrome, Edge, Firefox, and Safari. Test English and any other languages used on the page, especially when relying on inter-character.

Specifications

The text-justify property is defined in the CSS Text Module Level 3 specification.

CSS Text Module Level 3 - text-justify Property

The specification defines the available justification methods and how they interact with justified text alignment.

For additional documentation and examples, consult MDN Web Docs.

MDN Web Docs: text-justify