Problem: You’re trying to put your business phone number on your website, but part of the phone number wraps to a new line making it hard to read.
Thankfully, there’s a simple CSS class that will fix your problem.
The solution is extremely simple, wrap your phone number with a span tag and set the style of the white-space attribute of that span tag to be nowrap.
Here is example code that you can use:
<span style="white-space: nowrap;">
<a href="tel:+12345678900">1 (234) 567-8900</a>
</span>
Adding the CSS nowrap attribute results in:
Creating a NoWrap Class in Your Style Sheet
A really simple way to work around this would be to create a nowrap class, place it’s attributes into your style sheet, and then applying the class to HTML elements that you don’t want wrapping around.
Tip: You may want to double check your existing style sheet to verify that it doesn’t already have one, as many designers know that these reusable styles are very useful.
This code goes in your HTML file:
<span class="nowrap">
<a href="tel:+12345678900">1 (234) 567-8900</a>
</span>
This code goes in your CSS file:
.nowrap {
white-space: nowrap;
}