Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Auto break line in HTML

Tags:

html

css

I've been doing a comment box and I have a problem after viewing my comment. All I want is to make my comment auto break line when it exceeds the container but what I've got right now is a straight line.

For example:

tttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt

I hope my text can be like this:

ttttttttttttt
ttttttttttttt 
ttttttttttttt 
ttttttttttttt 

What should I use to make my text auto break line?

like image 302
Sigmund Grafia Avila Avatar asked May 02 '11 01:05

Sigmund Grafia Avila


People also ask

How do you put multiple line breaks in HTML?

Each <br /> tag inserts an additional line break on the page. Therefore, you can code multiple <br /> tags back-to-back to produce multiple blank lines down the page.

How do you break a line in HTML without br?

A line break can be added to HTML elements without having to utilize a break return <br> by using pseudo-elements. Pseudo-elements are used to style a specific part of an element. Here we will use ::after to style an HTML element to add a line break.


1 Answers

It sounds like you're after word-wrap: break-word, and its cross-browser variants.

See: https://developer.mozilla.org/en/CSS/white-space

selector {
      word-wrap: break-word;      /* IE 5.5-7 */
      white-space: -moz-pre-wrap; /* Firefox 1.0-2.0 */
      white-space: pre-wrap;      /* current browsers */
}

Demo: http://jsfiddle.net/MCj6s/

like image 185
thirtydot Avatar answered Oct 24 '22 12:10

thirtydot