How to set the width property for the style of span tag

Time:2020-6-29

If you set the width property directly to the style of the span tag, you will find that it will not have an effect.

If set display:block The width property takes effect, but the span is the same as div at this time.
If set display:inline-block , then span is listed on the same row, and the width property takes effect.

Description of common values of element display attribute:

1) Block: the default value of the block object. Forces the object to be presented as a block object, adding a new line after the object.
2) Inline: the default value for inline objects. Forces an object to be presented as an inline object, removing rows from the object.
3) Inline block: renders an object as an inline object, but the contents of the object as a block object. Adjacent inline objects are presented on the same line.
4) Non: hide the object. Unlike the hidden value of the visibility property, it does not reserve its physical space for hidden objects.