"If a worker wants to do his job well, he must first sharpen his tools." - Confucius, "The Analects of Confucius. Lu Linggong"
Front page > Programming > How Can I Make Text Wrap Around an Image Using HTML and CSS?

How Can I Make Text Wrap Around an Image Using HTML and CSS?

Posted on 2025-02-16
Browse:534

How Can I Make Text Wrap Around an Image Using HTML and CSS?

Wrapping Text Around an Image Using HTML/CSS

Question:

Can you design a block of text to wrap around an image like this:

[Image of text wrapping around an image]

Answer:

Yes, this is possible by floating the image container.

HTML:

CSS:

#container{
    width: 400px;
    background: yellow;
}
#floated{
    float: left;
    width: 150px;
    background: red;
}

Explanation:

  • The #container div defines the boundaries of the text and image.
  • The #floated div contains the text that will wrap around the image.
  • The float: left property on the #floated div makes it float to the left of the container.
  • The width property on the #floated div defines how wide the text will be.

Live Example:

[JSFiddle](http://jsfiddle.net/kYDgL/)

Latest tutorial More>

Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.

Copyright© 2022 湘ICP备2022001581号-3