/    Sign up×
Community /Pin to ProfileBookmark

Displaying HTML in a div without getting translated?

Can anyone tell me how to display HTML code inside a div without it getting translated by the browser? I tried the <code> tag, but it didn’t work. Any ideas? Thanks.

to post a comment
HTML

3 Comments(s)

Copy linkTweet thisAlerts:
@phpmyborderDec 13.2005 — <pre>

</pre>

and

<code>

</code>

can be used, but you need to mask the < > signs with &lt; and &gt;


or you can use php htmlspecialchars() if that is available...
Copy linkTweet thisAlerts:
@JazzcatCBauthorDec 13.2005 — <pre>

</pre>

and

<code>

</code>

can be used, but you need to mask the < > signs with &lt; and &gt;


or you can use php htmlspecialchars() if that is available...[/QUOTE]


Thanks for the suggestion to use htmlspecialchars(). That's just what I needed. I am encountering one problem though: I put 'n' chars in my string, and either stripslashes() or htmlspecialchars() seems to be removing them. Do you know how I can prevent this from happening? Thanks a lot.
Copy linkTweet thisAlerts:
@felgallDec 13.2005 — Use nl2br() first.
×

Success!

Help @JazzcatCB spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...