Assign width to span tag

Usually, you cannot directly assign width to a <span> tag because it defaults to an inline style. And that the width you assigned will have no effect.

Width property can only be assigned to elements that behaves like a block (i.e div)..

But if for some reasons you cannot use <div> and just want to adjust width of your <span>, you can always set it to behave like a block by changing the ‘display’ attribute to ‘block’ and then assign a width to your <span> tag.


<span style=”display: block; width: 20px;”>

The quick brown fox jumpls over the lazy, freaking dog.



Leave A Comment

Please be polite. We appreciate that. Your email address will not be published and required fields are marked