Umumnya penggunaan float pada CSS diperuntukan untuk konten gambar akan tetapi juga dapat di implementasikan pada konsep layout sehingga dalam 1 halaman web dapat membuat suatu bagian yang saling bersampingan.
Adapun contoh penggunaan float pada CSS dapat melihat potongan code dibawah ini :
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<style> | |
img { | |
float: right; | |
} | |
</style> | |
</head> | |
<body> | |
<p>In the paragraph below, we have added an image with style <b>float:right</b>. | |
The result is that the image will float to the right in the paragraph. | |
</p> | |
<p> | |
<img src="image/gambar.png" width="100" height="140"> | |
Lorem Ipsum is simply dummy text of the printing and typesetting industry. | |
Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, | |
when an unknown printer took a galley of type and scrambled it to make a type specimen book. | |
It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. | |
</p> | |
</body> | |
</html> |
Pada code diatas letak gambar akan berada disebelah kanan dari konten, karena penggunaan float: right; pada tag img ayang perlu diperhatikan adalah
Show Konversi KodeHide Konversi Kode Show EmoticonHide Emoticon