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

后端 未结 6 1692
情歌与酒
情歌与酒 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:39

    Least amount of markup possible (you only need one span):

    This text is left. This text is right.

    How you want to achieve the left/right styles is up to you, but I would recommend an external style on an ID or a class.

    The full HTML:

    This text is left. This text is right.

    And the CSS:

    .split-para      { display:block;margin:10px;}
    .split-para span { display:block;float:right;width:50%;margin-left:10px;}
    

提交回复
热议问题