Printable Version of Topic

Click here to view this topic in its original format

HTMLHelp Forums _ Cascading Style Sheets _ Right align part of sentence

Posted by: denmarks Sep 15 2021, 12:34 PM

How do a right align part of a sentence?

City name date time

I want "City name" to stay left but I want "date time" to tab and right align. I know I can add non breaking spaces but that is too much trouble and breaks if I widen the containing space.

Posted by: Christian J Sep 15 2021, 12:50 PM

If it's a table row I'd use two cells.

If it's a complete sentence, maybe you could float the two parts left and right.

If it's just a part of a sentence, please post a complete example because then I don't understand. laugh.gif


Posted by: denmarks Sep 15 2021, 12:52 PM

I figured it out. I used float: right.

Posted by: pandy Sep 15 2021, 06:17 PM

Actually, if it is a table and different cells, you can just align the parts left and right with text-align: left and right. Same goes if they are in different block level boxes, like P or DIV.

Posted by: Christian J Sep 15 2021, 06:21 PM

QUOTE(pandy @ Sep 16 2021, 01:17 AM) *

Same goes if they are in different block level boxes, like P or DIV.

Then you also need to make the block level elements appear on the same line, with e.g.:

CODE
display: inline-block; width: 50%;

Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)