How we can put two divisions <div> side by side in HTML?

HTMLWeb DevelopmentFront End Technology

With CSS properties, you can easily put two <div> side by side 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
Ali
Published on 01-Feb-2018 13:11:39
Advertisements