/

HTML / CSS / JavaScript Tutorial

CSS Property: text-justify

[this page | pdf | back links]

The CSS (CSS3) text-justify property indicates how text is justified when the text-align property has been set to justify.

 

Valid property values (other than inherit and initial) are:

 

Value

Description

auto

(default value). Browser determines justification

distribute

Primarily changes spacing at word separators and at grapheme boundaries in scripts other than connected and cursive scripts

inter-cluster

Primarily changes spacing at word separators and at grapheme boundaries in cursive scripts

inter-ideograph

Primarily changes spacing at word separators and at grapheme boundaries in connected scripts (i.e. ones that use no word spaces)

inter-word

Primarily changes spacing at word separators

kashida

Primarily stretches Arabic and related scripts through use of kashida or other calligraphic elongation

 

Default Value:

auto

JavaScript syntax:

e.g. object.style.textJustify="distribute"

Inherited:

Yes

Animatable:

No

 

EXAMPLE:


HTML USED IN THIS EXAMPLE:
<!DOCTYPE html>
<html> <!-- Copyright (c) Nematrian Limited 2018 -->
<head>
<style>
div {width: 100px; border: 2px solid red; text-align: justify}
.x1 {text-justify: distribute}
</style>
</head>
<body>
Not: not all browsers support this style<br><br>
1. Element with default property<br>
<div>abcde fgh a bcd</div><br>
2. Element set using in-file HTML style<br>
<div class="x1">abcde fgh a bcd</div><br>
3. Element set using JavaScript<br>
<div id="x2">abcde fgh a bcd</div>

<script>
document.getElementById("x2").style.textJustify = "distribute";
</script>

</body>
</html>

FUNCTION THAT MAY ASSIST IN TESTING WHETHER FEATURE IS SUPPORTED:
function isSupportedCSSPropertyTextJustify() {
  var x = document.createElement("DIV"); x.style.textJustify = "distribute"; return (window.getComputedStyle(x, null).textJustify == "distribute");
}


NAVIGATION LINKS
Contents | Prev | Next | CSS Properties


Desktop view | Switch to Mobile