How to align two divs horizontally in HTML?

HTMLWeb DevelopmentFront End Technology

To align two divs horizontally in HTML, use the float CSS property with left value. You can try to run the following code to learn how to align divs horizontally −

Example

Live Demo

<!DOCTYPE html>
<html>
<head>
<style>
.demo div {
    float: left;
    clear: none;
}
</style>
</head>
<body>
<div class="demo">
     <div>
        <span>div1</span>
        <select size="5">
           <option value="c1">India</option>
           <option value="c2">US</option>
           <option value="c3">UK</option>
           <option value="c4">Australia</option>
        </select>
    </div>
    <div>
        <span>div2</span>
        <select size="5">
           <option value="r1">1</option>
           <option value="r2">2</option>
           <option value="r3">3</option>
           <option value="r4">4</option>
        </select>
    </div>
</div>
</body>
</html>
raja
Published on 20-Dec-2017 15:21:19
Advertisements