How to place two divs next to each other in HTML?

jQueryWeb DevelopmentFront End Technology

With CSS properties, you can easily put two <div> next to each other in HTML. Use the CSS property float to achieve this.

With that, add height:100px and set margin.

Example

You can try to run the following code to place two <div> side by side −

Live Demo

<!DOCTYPE html>
<html>
<head>
<title>HTML div</title>
</head>
<body>
<div style="width: 100px; float:left; height:100px; background:gray; margin:10px">
First DIV
</div>
<div style="width: 100px; float:left; height:100px; background:yellow; margin:10px">
Second DIV
</div>
</body>
</html>
raja
Published on 20-Dec-2017 15:18:38
Advertisements