Home > Article > Web Front-end > How to Achieve Fixed Width in a Span Within an Unordered List without Modifying Padding or Tags?
Achieving Fixed Width in a Span within an Unordered List
When working with unordered lists, it can be desirable to align text after a fixed-width span. However, modifying the padding or adding/altering tags is not permissible. The following solution provides a means to achieve this goal without violating these restrictions:
Using CSS
An ideal approach would be to use the following CSS:
span { display: inline-block; width: 50px; }
This solution is effective in all browsers aside from Firefox 2 and earlier iterations. For these legacy browsers, consider using the -moz-inline-box value instead. However, be mindful that it behaves differently from inline-block and may produce unexpected results in certain scenarios.
The above is the detailed content of How to Achieve Fixed Width in a Span Within an Unordered List without Modifying Padding or Tags?. For more information, please follow other related articles on the PHP Chinese website!