Computer >> Computer tutorials >  >> Programming >> HTML

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


With CSS properties, you can easily put three <div> side by side in HTML. Use the CSS property float to achieve this.

With that, add height:100px and set margin.How we can put three divisions <div> side by side in HTML?

Example

You can try to run the following code to place three <div> side by side.

<!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>
      <div style="width: 100px; float:left; height:100px; background:red; margin:10px">
         Third DIV
      </div>
    </body>
</html>