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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Important lesson about using <pre> and innerHTML

Status
Not open for further replies.

tsdragon

Programmer
Dec 18, 2000
5,133
US
In the course of testing my reply to thread216-987714 I learned something very important about using <pre> tags and the innerHTML property: don't. Even though <pre> tags are supposed to preserve whitespace (including line breaks), when you use the innerHTML attribute to insert text into a <pre> tag it gets treated like HTML, not plain, preformatted text!

If you want to programmatically insert text into a <pre> section and you want to preserve the formatting like <pre> is supposed to, use the innerText attribute instead!


Tracy Dryden

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard. [dragon]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top