How to set fixed width in SPAN element using css?

Hello guys,
Just recently i found one case that span element is not taking the width property.
For example:

<span style="width:40px">rat32.com </span>

In the above code width property and values have no meaning. So in order to make it working we need to add float:left property. So the solution is:

<span style="float:left;width:40px">rat32.com</span>

Now this will set the width of span element. Hope it helps.
If it helped you please comment. Have a nice day!! 🙂

About the Author

has written 38 stories on this site.

2 Comments on “How to set fixed width in SPAN element using css?”

  • Naveen Niraula wrote on 19 October, 2017, 2:20

    Why not rat32.com ??

  • Naveen Niraula wrote on 19 October, 2017, 2:22

    Why not display: inline-block; width: 40px; ?

Write a Comment

Gravatars are small images that can show your personality. You can get your gravatar for free today!

*

Copyright © 2024 Programmer to Programmer- A website for web programming and mobile application programming tutorials.
Wordpress themes