Css Two Divs Next to Each Other

How to place two divs next to each other?

Float one or both inner divs.

Floating one div:

#wrapper {
width: 500px;
border: 1px solid black;
overflow: hidden; /* will contain if #first is longer than #second */
}
#first {
width: 300px;
float:left; /* add this */
border: 1px solid red;
}
#second {
border: 1px solid green;
overflow: hidden; /* if you don't want #second to wrap below #first */
}

or if you float both, you'll need to encourage the wrapper div to contain both the floated children, or it will think it's empty and not put the border around them

Floating both divs:

#wrapper {
width: 500px;
border: 1px solid black;
overflow: hidden; /* add this to contain floated children */
}
#first {
width: 300px;
float:left; /* add this */
border: 1px solid red;
}
#second {
border: 1px solid green;
float: left; /* add this */
}

CSS two divs next to each other

You can use flexbox to lay out your items:

#parent {  display: flex;}#narrow {  width: 200px;  background: lightblue;  /* Just so it's visible */}#wide {  flex: 1;  /* Grow to rest of container */  background: lightgreen;  /* Just so it's visible */}
<div id="parent">  <div id="wide">Wide (rest of width)</div>  <div id="narrow">Narrow (200px)</div></div>

How to place two divs next to each other?

Your border overflows here.

Try setting box-sizing: border-box to both divs:

#video{

width: 50%;
height: 100%;
border-style: solid;
float: left;
box-sizing: border-box;
}
#chat{

width: 50%;
height: 100%;
border-style: solid;
float: left;
box-sizing: border-box;
}

How to keep two div next to each other?

There are two issues here:

  1. You need to set a box-sizing so that the width of the element includes the border

  2. You need to remove the newline between the divs since it takes an extra space

div{
border: 1px solid;
display: inline-block;
box-sizing: border-box;
width: 50%;
}
<form>
<div>
two
</div><!-- you need to remove space here --><div>
one
</div>
</form>

Display two divs next to each other where each has a width of 50%

Because of two things

  1. Border size so you need to change box-sizing to border-box
  2. White space on inline-block elements