Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CONTENTEDITABLE problem with <p> tags

Status
Not open for further replies.

tristero

Programmer
Jan 24, 2003
95
US
I've written a javascript html editor but i'm having problems...

I'm using a <div> tag with contenteditable="true" as the main editor window.

the only problem is when i type in it it uses <P> tags for each new line.

this is causing a bouble-spacing effect. how do i keep this from happening? is it possible to disable the <p> tags ability to line break?


example:

i type this[hit enter]then this.


-and i get:

Code:
<p>i type this</p>
<p>then this.</p>

on the browser it looks like this:

i type this

then this.

please help!!!

Dan Trenz
Ann Arbor, MI
 
You could add CSS for your P tags to set margin and padding to 0px:

Code:
<style type="text/css">
p {
     margin: 0px;
     padding: 0px;
}
</style>

I know it's not the same, but if you only want this visual effect, it should work, and you could strip out the P tags later using a search-and-replace, etc.

Hope this helps,
Dan
 
thanks Dan! that's what i was looking for. i just couldn't figure out which style properties to change.


Dan Trenz
Ann Arbor, MI
 
Or you could hold the SHIFT key down while hitting ENTER to add a <BR> instead of <P></P>.

Adam
while(ignorance){perpetuate(violence,fear,hatred);life=life-1};
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top