When an element is floated, how do different display properties affect the layout? Or, what are the differences, if any, between these classes:
div.foo {
display: block;
float: left;
}
div.foo2 {
display: inline;
float: left;
}
div.foo3 {
display: inline-block;
float: left;
}
EDIT:
If there are no differences according to the spec, then do certain antiquated versions of browsers (ahem, IE) render them differently?
If I read the spec correctly, and practice confirms this, setting
float: left
orright
overrides thedisplay
property anyway and forcesdisplay: block
on the element (although with peculiarities, see below), so there will no difference between your three examples:Differently from normal
display: block
though, settingfloat
dictates its own behaviour in regards to width that override thedisplay
property: if no width was explicitly specified, the floated element will take up as much width as it needs, as opposed to standard block element behaviour of taking up 100% width automatically.