• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
Actual Wizard

Actual Wizard

Great Content From Actual Wizards

  • Blogging
  • Programming
  • Social Media
  • Marketing
You are here: Home / Programming / HTML

Prevent a Phone Number from Wrapping to a New Line in CSS HTML

May 4, 2019 by Kevin Marszalek

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.

Example of a phone number wrapping in html css
As you can see, the right hand portion of the phone number is wrapping to a new line.

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:

Now the phone number no longer wraps
Much better, the text now behaves in the way we would expect it to.

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;
}

Filed Under: HTML

Read More From Actual Wizard

  • Understanding the Different Parts of an Email Address
    An email address has four parts; the recipient name, the @ symbol, the domain name, and the top-level domain. …
  • How to Get the Last Element of an Array in JavaScript
    There are a number of different ways to get the last element of an array in JavaScript. Below we will explore …
  • How to use document.write() in JavaScript
    How to use document.write() in JavaScript The document.write() function is commonly used when testing simple …
  • How to Open a New Tab with JavaScript
    Opening a new browser window in a new tab can be done easily in JavaScript. Modern web browsers provide a …

Primary Sidebar

More posts from this section

  • PX to EM Converter – Online CSS Font Size Tool
  • How to Hide the URL Address in the Browser Status Bar
  • Heart Symbol HTML Code with Examples
  • HTML Trademark Symbol Code Example
  • Prevent a Phone Number from Wrapping to a New Line in CSS HTML
  • Html Tutorial Hello World Example with Code
  • Force a File to Download Instead of Opening it in a Browser with HTML

Copyright © 2025 ActualWizard.com

  • About
  • Terms of Service
  • Privacy Policy
  • Cookie Policy