Vertical border between floating DIVs using CSS

try to use

border-left:1px solid #color;
margin-left:2px;

and

border-right:1px solid #color;
margin-right:2px;

The simple one:

elements {
  border-left: black solid 1px;
}

elements:nth-child(1) {
  border-left: none;
}

I tried border on both divs, (right border on child-1 and left border on div-2, but this is not a good idea, because the line will appear thick where the two divs touch each other and then thin for the extended part.

That's a good way to go, actually. The final step, though, is to give the right div a negative left margin of 1px (assuming the border is 1px wide), so that the two borders overlap.

#child-1 {
    width: 500px;
    float: left;
    border-right: 1px solid gray;
}

#child-2 {
    width: 200px;
    float: left;
    border-left: 1px solid gray;
    margin-left: -1px;
}

Another option is to use display: table on the parent and then display: table-cell on the columns, and then have a single border line between them.

Tags:

Html

Css

Border