Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTML justify text-align with <pre> tag

I have a problem with the text-align "justify" inside a paragraph with format and fixed width, because I want the paragraph text in HTML to appear totally justified (like it would happen with a MS Word file). However, this does not happen. What I need to modify to achieve it?

     <pre style="color: #000000; font-family: Arial, Helvetica, sans-serif; font-size: medium; width: 500px; text-align: justify;"> 

I have a problem with the text-align "justify" inside a paragraph with format and fixed width, because I want the paragraph text in HTML to appear totally justified (like it would happen with a MS Word file). However, this does not happen. What I need to modify to achieve it?

        </pre>

EDIT: if I replace the <pre> tag with <p> tag, my code works properly. Can somebody explain me why? Perhaps I am using a wrong use of <pre> tag.

like image 694
julianfperez Avatar asked Jan 19 '12 01:01

julianfperez


People also ask

How do you center a pre tag in HTML?

In CSS, Simply set the pre to use display: flex; and assign center to the justify-content property.

What does pre >< code do?

The HTML <pre> tag defines a preformatted block of text. It comes in handy when you want to display text where the typographical formatting affects the meaning of the content, such as code snippets and poems.


1 Answers

  pre {
    text-align: left;
    white-space: pre-line;
  }
like image 80
Devalli Avatar answered Sep 28 '22 18:09

Devalli