Prevent Line Break

Simple example of how to prevent certain text from line breaking when not desired. For example, a phone number is displayed better if it doesn't break to the next line halfway through.

by Travis Almand

HTML

<div>this is a phone number (123) 456-7890 that will line break</div>
<div>this is a phone number <span class='nobr'>(123) 456-7890</span> that will not line break</div>
<div>this is a phone number <nobr>(123) 456-7890</nobr> that will not line break</div>

CSS

div {
    border: 1px solid black;
    margin: 20px;
    padding: 10px;
    width: 200px;
}
.nobr {
    white-space: nowrap;
}