Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Making html content unbreakable (in one line)

Tags:

I have a line made of inputs and spans which should represent a phone number. Inserting it into a table with some columns with content causes the line to break:

broken line

The last input is pushed into the next line. One way to fix this could be setting a fixed td width or min-width. However, for the sake of any future projects I would like to know is there a way to make the html content unbreakable without touching the td width. Thanks for any info.

like image 381
Przemek Avatar asked Feb 20 '12 13:02

Przemek


People also ask

How do you break a text with two lines?

We use the word–break property in CSS that is used to specify how a word should be broken or split when reaching the end of a line. The word–wrap property is used to split/break long words and wrap them into the next line.

How do you break a line into two lines in HTML?

Simply place the tag wherever you want to force a line break. Since an HTML line break is an empty element, there's no closing tag. Below is an HTML file with a <p> and <br> element. Since the <br> element is most commonly used to display poems or addresses, let's look at an example.

How do I stop text wrapping in CSS?

If you want to prevent the text from wrapping, you can apply white-space: nowrap; Notice in HTML code example at the top of this article, there are actually two line breaks, one before the line of text and one after, which allow the text to be on its own line (in the code).

How do you fit text in a box in CSS?

You have to set 'display:inline-block' and 'height:auto' to wrap the content within the border. Show activity on this post. Two ways are there. No need to mention height in this it will be auto by default.


1 Answers

Add this CSS to the td

white-space: nowrap; 

This prevents the automatic line-breaking of HTML. For more info see MDN

like image 159
Sirko Avatar answered Sep 21 '22 11:09

Sirko