Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

text-align justify not working

I'm trying to justify the text within this p tag so that it perfectly fits the width of the p.

<p align="justify" style="text-align: justify !important; color:#fff; margin:0px; font-weight:bold; width:487px; border:Solid 1px red;">blah blah blah</p> 

but the text just wont justify! any idea why?

thanks for any help.

like image 510
phil Avatar asked Jun 03 '11 14:06

phil


People also ask

Why is text-align center not working?

This is because text-align:center only affects inline elements, and <aside> is not an inline element by default. It is a block-level element. To align it, we will have to use something other than text-align , or turn it into an inline element.

How do I force justify in HTML?

In order to suggest that some text be justified on both sides, you can use the align="justify" attribute in HTML, or the text-align:justify declaration in CSS, or both.

Why You Should not justify text?

Justifying text disrupts that even texture. Even if a page layout program is using subtle letter-spacing, or adjusting the width of the letters – these things, too, will make the texture uneven. So, justified text should really be avoided not just on the web, but whenever possible.


1 Answers

You can use the solution described here: http://blog.vjeux.com/2011/css/css-one-line-justify.html

This will justify a single line but adds a space after, so if you know the height, you can specify it with overflow:hidden to conceal it and still get the justification.

.fulljustify {      	text-align:justify;      }      .fulljustify:after {          content: "";          display: inline-block;          width: 100%;	      }      #tagline {          height: 80px;          overflow: hidden;          line-height: 80px; /* vert-center */      }
<p id="tagline" class="fulljustify">Blah blah blah</p>
like image 134
manafire Avatar answered Sep 21 '22 21:09

manafire