Adding a newline automatically to a div

HTML, CSS and anything else that deals with client side capabilities.

Moderator: General Moderators

Post Reply
stom
Forum Newbie
Posts: 6
Joined: Thu Mar 11, 2010 1:04 pm

Adding a newline automatically to a div

Post by stom »

I have created an editable div box by using the following code.

<DIV id="textdiv" onClick="this.contentEditable='true';">
<PRE>this is the content</PRE>
</DIV>

and the following is the css for it

#textdiv {
position:absolute;
top:30px;
width:600px;
height:670px;
overflow:auto;
background:#DCDCDE;

}

Now when i start entering data into the div, I want it to automatically go to the newline when the data has reached the width size. Now if i keep on entering some characters, the data just keeps on getting added to the right and adds a scroll bar to the div.

Thanks!
Saj
rnoack
Forum Commoner
Posts: 34
Joined: Mon May 03, 2010 12:38 am

Re: Adding a newline automatically to a div

Post by rnoack »

this isn't really php so i think this is the wrong forum to ask this question.

also i don't know the solution.
User avatar
flying_circus
Forum Regular
Posts: 732
Joined: Wed Mar 05, 2008 10:23 pm
Location: Sunriver, OR

Re: Adding a newline automatically to a div

Post by flying_circus »

Code: Select all

#textdiv {
  position:absolute; 
  top:30px;
  width:600px;
  height:670px;
  overflow:auto; 
  background:#DCDCDE;
  word-wrap: break-word;
}
Post Reply