Home > Web Front-end > CSS Tutorial > How Can I Make Text Wrap Around an Image in HTML/CSS?

How Can I Make Text Wrap Around an Image in HTML/CSS?

Mary-Kate Olsen
Release: 2024-12-13 06:46:14
Original
815 people have browsed it

How Can I Make Text Wrap Around an Image in HTML/CSS?

Text Wrapping Around Images in HTML/CSS

Question:

Can we create a text block that wraps around an image like the image provided?

Answer:

Absolutely! To achieve this effect, it is necessary to float the image container. Here's how to do it:

HTML Code:

<div>
Copy after login

CSS Code:

#container {
    width: 400px;
    background: yellow;
}

#floated {
    float: left;
    width: 150px;
    background: red;
}
Copy after login

Result:

The container's fixed width (400px) and yellow background create a text block. The floated image (#floated) with a width of 150px and a red background is positioned on the left, allowing text to flow around it.

Interactive Example:

A live demonstration of this technique can be found on JSFiddle: http://jsfiddle.net/kYDgL/

The above is the detailed content of How Can I Make Text Wrap Around an Image in HTML/CSS?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template