Why doesn't #right
stay on the same line than the float: left
div #left
? whereas when not setting a width for #right
the behaviour is normal (see 2nd code snippet below).
* { margin:0; padding: 0; }
#left {background-color: green; float: left; width: 200px; }
#right {background-color: blue; width: 200px; }
<div id="menu">
<div id="left">Left</div>
<div id="right">Right</div>
</div>
The strange thing is, when I don't put any width for #right, then it works. Why does adding a width setting for #right make everything change?
* { margin:0; padding: 0; }
#left {background-color: green; float: left; width: 200px; }
#right {background-color: blue; }
<div id="menu">
<div id="left">Left</div>
<div id="right">Right</div>
</div>
Note: the question is really here : why does setting a width
change wrapping / not wrapping? The answer to this is not obvious in this related question.