Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Is it possible to float an image if it comes after the text in the html?

Floating an image to the right making text wrap around it is easy if the image comes before the text in the html.
But can it be done if the image comes after the text?
Like this:

<div class="text">Lorem ipsum</div>
<img src='...' alt=''>

See JsFiddle – how can the image be floated to the right of the text in such a case where I’m unable to change the html?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

But can it be done if the image comes after the text?

No, that’s not possible. float specifies how the content following the element you applied it to, behaves.

If you just want the image on the right, text on the left (without the text actually floating around the image, meaning going below the image as soon as there’s space), then use flexbox.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading