text-align justify not working

phil picture phil · Jun 3, 2011 · Viewed 93k times · Source

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.

Answer

manafire picture manafire · Feb 7, 2012

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>