I've always thought up to now that floating an element makes him an "inline-block". But now i am questioning this, since a floating "table" does not behave like an inline-block, and while making a "div" float makes the element behave like an inline-block, using the chrome inspect tool shows that the element it actually a "block". I am confused. If the element is "display:block", why does it behave like an inline-block then, i.e. the height and width become the height and width of the child-element or content? Does floating an element not make the element an inline-block?
HTML:
<div style="background-color:blue; padding:5px">
<div style="background-color:red">This is the child-div</div>
</div>
Now, as you can see, the container's width is 100% of its container, i.e. the body, and the width of the child-element is 100% of its container, i.e. the first "div".
Now, let's add "float" to the container.
<div style="background-color:blue; padding:5px; float:right">
<div style="background-color:red">This is the child-div</div>
</div>
Now, as you can see, the width of the container has collapsed. It's not 100% of its container anymore, it's now taken the width of its child-element, exactly what it expected from an inline-block element.
Example with an inline-block:
<div style="background-color:blue; padding:5px; display:inline-block">
<div style="background-color:red">This is the child-div</div>
</div>
As you can see, we see the same behavior. The width of the container becomes the width of the child-element. Floating and Inline-block therefore behave the same with the exception that inline-block elements obviously don't float right or left, they stay on place.
So, my question is, why does floating a block-level element makes it behave like an inline-block element, if it does not actually become an inline-block element?