I have a line made of input
s and span
s which should represent a phone number. Inserting it into a table with some columns with content causes the line to break:
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.
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.
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.
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).
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.
Add this CSS to the td
white-space: nowrap;
This prevents the automatic line-breaking of HTML. For more info see MDN
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With