HTML/CSS: how to put text both right and left aligned in a paragraph

后端 未结 6 1690
情歌与酒
情歌与酒 2020-12-28 18:54

What would be the best code to have two bits of text in a single paragraph, one left aligned, the other right aligned, that also is:

  • the least code as possible
6条回答
  •  心在旅途
    2020-12-28 19:48

    The only half-way proper way to do this is

    Text on the right Text on the left

    however, this will get you into trouble if the text overflows. If you can, use divs (block level elements) and give them a fixed width.

    A table (or a number of divs with the according display: table / table-row / table-cell properties) would in fact be the safest solution for this - it will be impossible to break, even if you have lots of difficult content.

提交回复
热议问题