tags:

views:

149

answers:

4

Google fail, I used to know what it was years ago...

Basically would make <theTag><img src='cat.jpg'/></theTag> render as <img src='cat.jpg'/> rather than actually displaying the image...

+8  A: 

The tag is <xmp>, but it's deprecated.

A better way to go is to replace < and > with &lt; and &gt;, respectively. Also, & with &amp;, and you should be perfectly safe.

David Hedlund
Well, it was over 10 years ago that I learned it ;D Thanks for your reply.
SLC
Man you guys are fast!!!! Haha.. +1
o.k.w
It was deprecated in 1997 (if not before).
David Dorward
Shh, you make me feel old ;(
SLC
@SLC: At least you've forgot about it and moved on. I don't know how the rest of us can defend remembering stuff that hasn't been approved of since before HTML 4 =)
David Hedlund
A: 

You’re probably talking about CDATA sections?

<![CDATA[<img src='cat.jpg'/>]]>

Be careful though, this doesn’t work very well in some browsers. Plus, I think it doesn’t exist in HTML, only in XML. It exists in HTML but browser support is not reliable. It’s better to just escape everything.

Konrad Rudolph
This also only works in XHTML if I know anything about it.
Matthew Scharley
@Matthew: yes, I believe that as well but I wasn’t sure.
Konrad Rudolph
CDATA marked sections are part of SGML and thus part of HTML too — it's just that nothing supports it.
David Dorward
@David: yes, I’ve corrected that.
Konrad Rudolph
A: 

What about <pre>? As far as I understand it's made exactly for these cases.

Pekka
Nope, it doesn't. It preserves formatting (such as multiple spaces), but it doesn't ignore HTML tags.
David Hedlund
To get `<span>this is a span</span>` within a `<pre>` you need this: `<pre><span>this is a span</span></pre>`
o.k.w
oh, o.k. then I have been misusing it :) Thanks for the info.
Pekka
A: 

i think you are looking for the <xmp> tag but that is nowhere near valid HTML anymore :)

http://www.w3.org/TR/REC-html32#xmp

ChrisR