I have two div
s followed, one has width
100px
and the other 200px
. Adding the width of the two (300px) is well below the viewport width of the screen (on a desktop screen, for example), but the second appears below the first:
body{
margin: 0;
}
#lateral{
width: 100px;
background: red;
}
#main{
width: 200px;
background: blue;
}
<div id="lateral">
lateral
</div>
<div id="main">
main
</div>
My doubts are as follows:
Does a div
always fall below the other regardless of the width, or do you always have to use float
so that one side is next to the other? Does div
always force a "line break" in the layout? Why does not the width of the two sums exceed the width of the screen?
If I use float: left
it would solve, but I did not want to use float
because if I wanted to centralize both side by side float
would prevent this.
I do not have advanced knowledge in CSS, and some situations seem confusing to understand, such as this, for example.