Ste
Ste

Reputation: 11

HTML/CSS div line break

I'm creating a page where the users can post comments, but I have some problems with the div which contains the message posted. If it's too long and without line breaks, it appears a horizontal scrollbar. I would like to make the text automatically go in the following line like the comments posted in this site.

Have you got some ideas for making this happen?

I use chrome as browser and asp.net is the server language.

I create the div with:

Response.Write("<tr><td><div class=""target-div"">" & reader("commento").Replace(vbCrLf,"br/>") & "</div></td></tr>")

Upvotes: 1

Views: 1161

Answers (1)

Ortiga
Ortiga

Reputation: 8814

I think it's

.target-div {
    white-space:pre-wrap;
}

pre-wrap both saves user formatting (i.e., preserves multiple white-spaces) and wrap when necessary

Upvotes: 2

Related Questions