The following point is interesting:
Many places write that they say if the element is assigned the property float:left; or float:right; then the display will be set to block !
But I do not agree!
Example:
.a { float:left; background:yellow; } .b { width:100px; background:red; display:inline-block; } <div class="a">This is Photoshop 1.</div> <div class="b">This is Photoshop 2.</div> Result: One unit will be in line with the other.
But this is possible when there is an inline-block for both elements. Otherwise, it would be impossible to place 2 blocks on one line, because the whole width would be occupied by a block with display:block; .
Here is another example:
.a { float:left; background:yellow; opacity:0.7; padding:5px; } .b { background:red; display:block; } <div class="a">This is Photoshop 1.</div> <div class="b">This is Photoshop 2.</div> Result: one block in a row with another, but behind that only difference that the float element is ignored and the block takes the place under it. Although the text is outside the first block
In the code inspector, an element with float:left; shows display:block; ... again it is not clear! I described my point of view. Explain to me if I misunderstood something.
PS Who did not understand the question!
Why an element with a display:inline-block; property value display:inline-block; , which stands after the element with the property value float:left; is on the same line? (If you hold the same but without float:left; then the elements will not be on the same line because display:block; will take the whole width).
floatnothing to do withdisplay. You have a display: block, because this is the standard value of this property for the div element - Grundyinline-block. - Andrey Fedorov