A div not staying on the same line of the float: left div

Below codes shows “right” in new line ,but if we remove width for right,the right text comes in same line with left.Why it is working in a such way?

* { 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>

Welcome @shashanka !

the code didn’t format correctly, you’re missing a ` at the start,

is it possible to post a codepen or sandbox code of what you have?

1 Like

Are you going for something like this?

… I’m not good with float to be honest. I use flexbox for all of my projects.