In this In this post we will learn about how html 2 divs side by side. There are several ways to put html 2 divs side-by-side.

Here are the subsequent steps you need to follow:

So basically there are 2 steps where within the first step you need to create an HTML File and then in the second step you need to add CSS styling.

Create HTML

  • Create a <main> tag in the <body> section with the id “boxes” which should include our <div> elements.
  • Create <div> elements. For our first <div> we use id with the name ”column1”, for second id “column2”.
  • You can set titles for your <div> elements using <h2> tags.
you can also learn : Python Script Run on Clicking Html Button Part 2 – Hackanons


  • Use the float property to define on which side of the container the elements should be placed. The float property has three values (none, left, and right). In our example, we use the “left” value for the <div> elements.
  • You can choose colors for the background by using the background-color property.
  • Set the dimensions of your with the width and height properties.
  • Set the position for titles using the text-align property.
  • Use the clear property which is directly associated with float property. It defines whether a component should be next to floating elements, or it should be below them (clear).
  • Use the content property. The content property is used with the before and after pseudo-elements to generate content inside an element.
  • Use the display property, which makes the element behave like an HTML <table> element.
HTML For Beginners The Easy Way: Start Learning HTML & CSS Today » 

Let’s bring the code parts together to work out the result!

So here is an example Example of html 2 divs side by side

Conclusion :

To sum up, this post has shown the way how html 2 divs side-by-side  you’ll try these above ways,you’ll share it in the comment zone

Categorized in:

Tagged in: