I would like to limit the width of a block of text so it will look like it has br at the ned of each line.
Something like this:
Texttttttttttttttttttttt tttttttttttttttttttttttt tttttttttttttttttttttttt
From this:
Texttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt
I have tried to specify the div's or p's width, but it didn't work for me. Any suggestions?
The HTML <input> tag is used to get user input in HTML. To give a limit to the input field, use the min and max attributes, which is to specify a maximum and minimum value for an input field respectively. To limit the number of characters, use the maxlength attribute.
You can use the CSS property max-width and use it with ch unit. And, as this is a <span> , use a display: inline-block; (or block). Thanks , max-width: 13ch and display:inline-block allow me to concatenate text one by one with fixed size.
1. Set width in HTML. In HTML, you can use the width attribute to set the width of an element. Alternatively, you can also use the size attribute to define the width of the <input> .
display: inline-block; max-width: 80%; height: 1.5em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
You can apply css like this:
div { word-wrap: break-word; width: 100px; }
Usually browser does not break words, but word-wrap: break-word;
will force it to break words too.
Demo: http://jsfiddle.net/Mp7tc/
More info about word-wrap
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