Justify contents of a variable

Asked

Viewed 163 times

0

I am working with texts, reading what was typed by the user and saving in the variable subject matter. I would like that, when the variable was called, its contents be shown on the screen with justified alignment. But I’ve tried some ways:

echo "<div style='text-align: justify;'>".$assunto."</div>";

echo "<p align='justify'>".$assunto."</p>";

And I had no result. How can I show the contents of a variable with justified alignment?

1 answer

2


It’s by CSS, just like you tried to do in the first example, but it’s just justify, nay justifictify. Take an example:

p {
  text-align: justify;
}
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam non gravida nisi. Fusce in nisi ut lorem aliquam tempus. Mauris aliquet maximus nulla a luctus. Etiam finibus nisl quis dignissim lacinia. Praesent arcu nunc, tristique quis dui eu, finibus ultrices lorem. Proin eget leo ultricies, scelerisque nulla et, blandit metus. Aliquam tincidunt lorem neque, sit amet maximus nulla cursus in. Nullam vel odio rhoncus, accumsan elit et, aliquam diam. Duis et leo vel metus iaculis tincidunt non a lacus. Nulla a feugiat augue, ut tincidunt erat. Maecenas nec interdum odio, eu luctus risus. Suspendisse sed erat lectus. Proin fermentum consequat justo sit amet imperdiet. Vestibulum tellus eros, facilisis nec imperdiet non, consectetur id turpis. Sed tempus congue mauris nec sagittis. Suspendisse at ante sit amet metus consectetur accumsan.</p>
<p>Ut aliquet tincidunt odio, nec sodales est. Cras faucibus vestibulum urna, nec tincidunt nisi iaculis et. Ut condimentum nunc eu sapien pharetra, vel pretium risus interdum. Suspendisse gravida leo at tellus gravida, sit amet rhoncus eros sagittis. Sed tristique ante lectus. Phasellus a malesuada lacus. Sed nec eros eu nibh scelerisque laoreet. Mauris non lacus vel ex maximus varius at auctor mi. Morbi nunc augue, iaculis eget libero id, efficitur dapibus sem. Integer viverra, neque quis egestas consectetur, massa elit sollicitudin orci, vel dapibus diam nibh ac arcu. Nulla tristique quis mi in facilisis. Nulla arcu ipsum, ullamcorper vel dictum ac, pharetra et ligula. Nullam congue vestibulum bibendum. Suspendisse aliquet porta mauris nec mattis. Morbi tempus eros sed dolor molestie convallis ac sit amet enim.</p>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.