Krut
Krut

Reputation: 31

how to display < html tags without escaping nightmare

I want to be able to indicate a part of the HTML file where i can simply type <asd><qwe> and they will be displayed as such (i mean the text).

I am aware we can do this: <asd><qwe> but it slowly becomes a nightmare..

I tried:

<pre><asd><qwe></pre>

but it isn't working..

Upvotes: 1

Views: 954

Answers (7)

Nishchay Sharma
Nishchay Sharma

Reputation: 1324

See you have two options :

  • In your text editor "Find and Replace All" all "<" with "<" and all ">" with ">"

  • And as posted by Oltarus, if your server supports php then just use:

    <?php echo htmlentities("<html><head></head></html>"); ?>

Upvotes: 0

&#193;lvaro Gonz&#225;lez
&#193;lvaro Gonz&#225;lez

Reputation: 146650

Your question is incredible vague but you are probably looking for about the <XMP></XMP> tag set. However, such element has been deprecated for quite long: you can use it for some quick testing but it has no place in a live site.

The only serious approach is to use a server-side language that takes care of escaping for you.

Upvotes: 0

Mathias Schwarz
Mathias Schwarz

Reputation: 7197

Technically you can put you data in a <![CDATA[...]]> construct. However, it is poorly supported by browsers, so you have to live with the escaping. You best option is probably to use an editor that can help you escaping.

Upvotes: 0

GordonM
GordonM

Reputation: 31780

Escaping HTML special characters (not just < and > but several others as well) is your only option I'm afraid. However there's quite a few editors that can do this for you

Upvotes: 0

Kevin Bowersox
Kevin Bowersox

Reputation: 94499

Why not use an online tool like Quick Escape: http://accessify.com/tools-and-wizards/developer-tools/quick-escape/

Write whatever you would like without escaping it. Then copy and paste it into Quick Escape and it will return it escaped.

Upvotes: 1

SteeveDroz
SteeveDroz

Reputation: 6156

Replace all you < by &lt; (lt = less than) and all your > by &gt; (gt = greater than).

If you're using some PHP, you can simply use htmlentities(), which will do that alone.

Upvotes: 0

Quentin
Quentin

Reputation: 944528

HTML 4.x (technically) supports CDATA sections (which do what you want), but browsers don't (except in XHTML served as application/xhtml+xml which isn't supported by IE < 9).

Use &lt; and friends. An editor with Find & Replace stops it being a nightmare.

Upvotes: 1

Related Questions