html 2 div side by side code example

Example 1: how to align two divs side by side

.wrapper {
    display: flex;
    flex-wrap: wrap;
}

.wrapper>div {
    flex: 1 1 150px;
    height: 500px;
}

Example 2: place div side by side

<div style="width: 100%; display: table;">
    <div style="display: table-row">
        <div style="width: 600px; display: table-cell;"> Left </div>
        <div style="display: table-cell;"> Right </div>
    </div>
</div>

Example 3: display two divs side by side flexbox

.grid-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-gap: 20px;
}

Example 4: display two divs side by side flexbox

.float-container {
    border: 3px solid #fff;
    padding: 20px;
}

.float-child {
    width: 50%;
    float: left;
    padding: 20px;
    border: 2px solid red;
}

Tags:

Html Example