Giới thiệu
Để dùng ảnh nổi (floating image) trong HTML, dùng thuộc tính CSS float. Nó cho phép nổi ảnh sang trái hoặc phải. Các giá trị thuộc tính khác:
| Giá trị | Mô tả |
|---|---|
| none | Không nổi (mặc định) |
| left | Nổi sang trái |
| right | Nổi sang phải |
| initial | Giá trị mặc định |

Ví dụ
<!DOCTYPE html>
<html>
<head>
<title>HTML Floating Image</title>
</head>
<body>
<h1>Float Right</h1>
<p>The below image floats to the right.</p>
<p>
<img src="https://www.tutorialspoint.com/green/images/logo.png" style="float:right" width="190" height="84" />
This is demo text. This is demo text. This is demo text. This is demo text. This is demo text. This is demo text. This is demo text. This is demo text. This is demo text. This is demo text. This is demo text. This is demo text.
</p>
<h1>Float Left</h1>
<p>The below image floats to the left.</p>
<p>
<img src="https://www.tutorialspoint.com/green/images/logo.png" style="float:left" width="190" height="84" />
This is demo text. This is demo text. This is demo text. This is demo text. This is demo text. This is demo text. This is demo text. This is demo text. This is demo text. This is demo text. This is demo text. This is demo text.
</p>
</body>
</html>
Kết quả
