blob: 7390fff7874d5984f1a45d1b4ff75a632a8417fb (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
---
layout: post
title: "Text Align: Justify"
date: 2019-05-22
---
The text-align property is fairly well known in the world of CSS, even among those just starting out with the language. Values such as `center`, `left` and `right` are used often with this property, but a more forgotten option is `justify`.
## What does justify do?
The MDN web docs define the `justify` value for `text-align` as such:
<blockquote>
<p>The inline contents are justified. Text should be spaced to line up its left and right edges to the left and right edges of the line box, except for the last line.</p>
<cite><a href="https://developer.mozilla.org/en-US/docs/Web/CSS/text-align">MDN web docs</a></cite>
</blockquote>
### See it in action
[Live CodePen Example](https://codepen.io/bradleytaunt/pen/vwpmNz/)
## When should I use this?
It isn't always appropriate to use `justify` in most instances, although it becomes very useful for long form articles or blog posts. Since it takes a heavy influence from original *print* book layouts, the `justify` value helps improve readability for larger chunks of content.
**Fair warning**: it is best to remove any `justify` values when targeting smaller screen sizes. Mobile devices and/or tablets tend to be small enough to break up the content already. This CSS value is better suited for larger viewports.
## Browser support
The good news is that all major browsers support the `justify` value for the `text-align` CSS property. So have some worry-free fun with it!
|