shu shu - 7 months ago 42
HTML Question

float property for inline element

Can we apply float property to inline element? if we could, is there any difference between a floated inline-box and a floated block-box, like this two elements:

<span style="float: left;">hello</span>
<span style="float: left; display: block;">hello</span>

thank you!


In accordance with CSS rules, when you apply float to an element, in most cases it becomes a block element. Elements that are inline and inline-block will compute to block.

From MDN:

enter image description here