Search code examples
htmlcsscss-floattext-align

How to display Text after an Image on a new line left aligned, instead of wrapping around the image?


This is my code:

<P>
<div><img style="border: 0pt none; float: left; padding-right: 10px; padding-bottom: 10px;" src="Image.jpeg" alt="Image" width="150" height="150" />This is text wrapped around Image</div>
</P>
<P>
<div>
<h2 align="left">This text should left align</h2>
</div>
</P>

I want to display "This text should left align" as aligned left side in a new line

I used Div and P tags for this, If there's something else.


Solution

  • Your HTML needs some work - you cant have a h2 inside a p. However, if i understand you correctly, you want something like this:

    <div>
        <img style="float:left;padding-right:10px;padding-bottom:10px;" 
             src="Image.jpeg" alt="Image" width="150" height="150" />
        This is text wrapped around Image
    </div>
    
    <h2 style="clear:left;">This text should left align</h2>
    

    https://jsfiddle.net/g08hycaf/