Search code examples
csshtmltextalignment

HTML5 Have left aligned text and right aligned text in same line within paragraph


I want to have "This is a test" left aligned and "[Rare photograph]" right aligned but still be on the same line.

I'm a newbie at HTML5, so a simple explanation would be appreciated.

Thanks! :)

<p style = "margin-left:75px;max-width:750px;"><br/>
        This is a test.
        [Rare photograph]


</p>

Solution

  • You can't do that without an additional tag, but what you can do is inject a <span> tag within a <p> tag, and give each <span> a respective float: left and float: right:

    <p style="margin-left: 75px; max-width: 750px;">
      <span style="float: left">This is a test.</span>
      <span style="float: right">[Rare photograph]</span>
    </p>

    Hope this helps! :)