Be a Supporter!

HTML question...

  • 311 Views
  • 3 Replies
New Topic Respond to this Topic
MrMojoRisin5
MrMojoRisin5
  • Member since: Jun. 21, 2011
  • Offline.
Forum Stats
Member
Level 12
Programmer
HTML question... 2013-03-03 09:03:05 Reply

I want to use some HTML script as plain text, but even though I have tried putting it in header, paragraph or script tags, it is still seen by the browser as actual HTML script and it won't display. Does anybody know how to solve this?


-Got to keep on risin'...
-Check out FlashFrame
-Check out my YouTube channel and my blog

BBS Signature
deckheadtottie
deckheadtottie
  • Member since: Oct. 21, 2003
  • Offline.
Forum Stats
Supporter
Level 59
Programmer
Response to HTML question... 2013-03-03 10:13:29 Reply

At 3/3/13 09:03 AM, MrMojoRisin5 wrote: I want to use some HTML script as plain text, but even though I have tried putting it in header, paragraph or script tags, it is still seen by the browser as actual HTML script and it won't display. Does anybody know how to solve this?

I don't really know what you mean. Do you want to display HTML elements in the document without them being parsed by the browser? Like the code tags below allow:

<p>These HTML elements aren't being displayed as they should as they're in code tags</p>
<em>this won't be in italics</em>

Post some code and an example of what you want to achieve. :)


#coys

BBS Signature
Diki
Diki
  • Member since: Jan. 31, 2004
  • Online!
Forum Stats
Moderator
Level 13
Programmer
Response to HTML question... 2013-03-03 17:04:12 Reply

In order to do that you need to replace the <> brackets, and ampersand, with their HTML character codes. The code for < is &#60;, the code for > is &#62;, and the code for an ampersand is &amp;. You can do a simple find/replace to insert the codes in place of the literals.

I'm going to assume your server is running on Apache and you're to some extent using PHP in which case all you have to do is use the htmlspecialchars() function:

$html = "<p>This is some text <em>with html</em> in it.</p>
$safe = htmlspecialchars($html);

echo $safe;
smulse
smulse
  • Member since: Mar. 24, 2005
  • Offline.
Forum Stats
Member
Level 31
Blank Slate
Response to HTML question... 2013-03-05 14:26:28 Reply

http://dev.w3.org/html5/spec-author-view/the-pre-element.htm l#the-pre-element

<pre> </pre>

BBS Signature