
- CSS Tutorial
- CSS - Home
- CSS - Introduction
- CSS - Syntax
- CSS - Inclusion
- CSS - Measurement Units
- CSS - Colors
- CSS - Backgrounds
- CSS - Fonts
- CSS - Text
- CSS - Images
- CSS - Links
- CSS - Tables
- CSS - Borders
- CSS - Margins
- CSS - Lists
- CSS - Padding
- CSS - Cursors
- CSS - Outlines
- CSS - Dimension
- CSS - Scrollbars
- CSS Advanced
- CSS - Visibility
- CSS - Positioning
- CSS - Layers
- CSS - Pseudo Classes
- CSS - Pseudo Elements
- CSS - @ Rules
- CSS - Text Effects
- CSS - Media Types
- CSS - Paged Media
- CSS - Aural Media
- CSS - Printing
- CSS - Layouts
- CSS - Validations
- CSS3 Tutorial
- CSS3 - Tutorial
- CSS3 - Rounded Corner
- CSS3 - Border Images
- CSS3 - Multi Background
- CSS3 - Color
- CSS3 - Gradients
- CSS3 - Shadow
- CSS3 - Text
- CSS3 - Web font
- CSS3 - 2d transform
- CSS3 - 3d transform
- CSS3 - Animation
- CSS3 - Multi columns
- CSS3 - User Interface
- CSS3 - Box Sizing
- CSS Responsive
- CSS - Responsive Web Design
- CSS References
- CSS - Questions and Answers
- CSS - Quick Guide
- CSS - References
- CSS - Color References
- CSS - Web browser References
- CSS - Web safe fonts
- CSS - Units
- CSS - Animation
- CSS Resources
- CSS - Useful Resources
- CSS - Discussion
How to Justify Text using text-align & text-justify CSS Properties?
CSS text-justify property helps us specify the justification type for an element. The text-align property sets the horizontal alignment of text in an element.
Example
The following examples illustrate CSS text-justify property.
<!DOCTYPE html> <html> <head> <style> article { margin: 3%; background-color: peachpuff; text-align: justify; } p:first-of-type{ text-justify: inter-character; background-color: moccasin; } </style> </head> <body> <article> <p>Nullam in fringilla ex, at sagittis erat. Praesent imperdiet augue at ante tempor, eu condimentum tellus consectetur. Mauris rutrum, lectus quis porta bibendum, arcu neque dictum orci, sed volutpat ipsum risus in ex. Suspendisse potenti. Nam rhoncus ultricies nisi pulvinar rutrum. Mauris ullamcorper interdum urna a vulputate. Quisque dolor tortor, vehicula in odio eu, fringilla rutrum est. Nunc viverra congue aliquam. Ut volutpat magna ipsum, in interdum velit mollis ac. </p> <p>Nullam in fringilla ex, at sagittis erat. Praesent imperdiet augue at ante tempor, eu condimentum tellus consectetur. Mauris rutrum, lectus quis porta bibendum, arcu neque dictum orci, sed volutpat ipsum risus in ex. Suspendisse potenti. Nam rhoncus ultricies nisi pulvinar rutrum. Mauris ullamcorper interdum urna a vulputate. Quisque dolor tortor, vehicula in odio eu, fringilla rutrum est. Nunc viverra congue aliquam. Ut volutpat magna ipsum, in interdum velit mollis ac.</p> </article> </body> </html>
Output
This will produce the following result −
Example
<!DOCTYPE html> <html> <head> <style> dl { margin: 3%; background-color: lightcoral; text-align: justify; } #example{ text-justify: inter-character; background-color: snow; } </style> </head> <body> <dl> <dt> Quisque dolor tortor, vehicula in odio eu, fringilla rutrum est.</dt> <dd>Nunc viverra congue aliquam. <p id="example">Nullam in fringilla ex, at sagittis erat. Praesent imperdiet augue at ante tempor, eu condimentum tellus consectetur.</p> </dd> </dl> <dl> <dt> Quisque dolor tortor, vehicula in odio eu, fringilla rutrum est.</dt> <dd>Nunc viverra congue aliquam. <p>Nullam in fringilla ex, at sagittis erat. Praesent imperdiet augue at ante tempor, eu condimentum tellus consectetur.</p> </dd> </dl> </body> </html>
Output
This will produce the following result −
- Related Articles
- text-justify Property in CSS
- How to Justify Text in TextView on Android?
- How to Justify Text in TextView in Android?
- CSS text-align-last property
- How to justify text in label in tkinter in Python Need justify in tkinter?
- Center image using text-align center with CSS?
- How to Align Text Strings using Python?
- Usage of text-align property in CSS
- How to align text content into center using JavaScript?
- Align the text of a document with CSS
- Align the text of a paragraph with CSS
- How to align text in CSS where both columns are straight?
- Text Indentation using CSS
- Text Decoration Using CSS
- Formatting Text Using CSS

Advertisements