PDA

View Full Version : Text align justify & center?


paulprice85
05-09-2010, 07:47 AM
Hi, I'm trying to justify my text so it looks smooth on the left and right but as a paragraph when i state 'text-align:justify;' the paragraph is justified but its to the left. how do I make it justified and in the center?

Thanks

Corrosive
05-09-2010, 08:14 AM
That's odd. Justify means to have it fill the same space left and right. Like a newspaper column. You got a link Paul?

paulprice85
05-09-2010, 08:42 AM
yeah sure. here it is. just did a quick upload so everything else is missing

http://aboutpaul.co.uk/test.html

Corrosive
05-09-2010, 08:50 AM
Looks justified in my browser (Chrome) mate.

paulprice85
05-09-2010, 10:18 AM
What I mean is, is the bottom line to the left or in center? I wondered if there was a way to shift that bottom line over to the middle

gentleone
05-09-2010, 03:29 PM
What I mean is, is the bottom line to the left or in center? I wondered if there was a way to shift that bottom line over to the middle

No, with 'text-align: justify' the last line of the paragraph will always go to the left. If it wasn't like that, than the last line would end up with large spaces in between the words. I assume that's not what you want on your page.

What you can try with that last line, but I'm not sure if this will screw up the line before the last line, is that you give it an inline style like this.

<span class="last-line">features, for your peace of mind.</span>CSS:

.last-line {text-align: center}

d a v e
05-09-2010, 09:13 PM
you could do that but you don't know for sure where the last line starts in every browser.

if you want fully justified text then this is how it is. You may also find that for some lines the length is compromised by the justification, and you may get 'rivers' of white running through the lines of text.

gentleone
05-09-2010, 09:28 PM
you could do that but you don't know for sure where the last line starts in every browser.

if you want fully justified text then this is how it is. You may also find that for some lines the length is compromised by the justification, and you may get 'rivers' of white running through the lines of text.

Good point, dave! I didn't think ahead :)
So... justify is just how justify is, Paul!

domedia
05-09-2010, 10:58 PM
text-align-last in CSS3 will eventually solve this.

Currently only one browser supports it... <drumroll> Internet Explorer.,, Go figure.

p {
text-align: justify;
text-align-last: center;
}

paulprice85
05-10-2010, 07:42 AM
:-) thanks guys, that clears that up good and proper!

d a v e
05-10-2010, 08:51 AM
text-align-last in CSS3 will eventually solve this.

Currently only one browser supports it... <drumroll> Internet Explorer.,, Go figure.

p {
text-align: justify;
text-align-last: center;
}

yes but *which* version of internet explorer ie7, 8,9 preview 2??

domedia
05-10-2010, 02:45 PM
Ie8 only, there's no other way afaik.

jmichae3
12-06-2010, 10:23 AM
Hi, I'm trying to justify my text so it looks smooth on the left and right but as a paragraph when i state 'text-align:justify;' the paragraph is justified but its to the left. how do I make it justified and in the center?

Thanks

I just wrote 2 solutions for this problem.
both involve setting the width of the column you want "centered".
http://JesusnJim.com/common/centered-justified-text.html

domedia
12-08-2010, 02:25 PM
jmichae3, I'm not seeing the last line centered in your link. They're all left justified.

DWcourse
12-08-2010, 03:45 PM
jmichae3, I'm not seeing the last line centered in your link. They're all left justified.

Ditto, same here.

bee80
12-09-2010, 07:55 AM
I just wrote 2 solutions for this problem.
both involve setting the width of the column you want "centered".
http://JesusnJim.com/common/centered-justified-text.html


That site is terrible