CodeSteps

Python, C, C++, C#, PowerShell, Android, Visual C++, Java ...

How to align div tags side by side?

An HTML <div>tag is used to define a section in an HTML document. This tag is more often used to create web-layouts. Some times, it is required to place two <div> tags side by side. As it is not straight forward, below steps are helpful to achieve this:

Step 1. First, write the HTML code with two <div> tags. Place the required information inside each element.

Step 2. Second, use the HTML attribute style with the property float is defined with proper values. The values of the property float is depending on your requirement. For example, if the <div> tag will be shown in left side, you need to set the property value for float as left.

Step 3. Third, Refresh the webpage, to see the updated changes affected.

Following is the HTML code for this:

DIV Tag 1 Code:

<div style=”float: left;”>This is the first DIV tag.</div>

DIV Tag 2 Code:

<div style=”float: right;”>This is the second DIV tag.</div>

 

 

 

 

How to align div tags side by side?
Scroll to top