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

Is there an "ignore HTML" tag in HTML? (like <PRE>)

Status
Not open for further replies.

Spab23

Programmer
Jul 22, 2003
43
CA
I am trying to display some HTML code on an HTML rendered page. Is there a tag that will let me do this? I am using <PRE> but it still renders other embedded HTML tags within the <PRE> tags. I want to be able to write <table><tr><td>... etc without the table being created.

Will I have to resort to using escape sequences like & gt ; and & lt ; to hide the tags?

Thanks!
 
Thanks, Fendal.

I was thinking that there couldn't possibly be such a tag because if you turn of HTML rendering, then how could the browser render the close tag? I guess it says "print every character on the screen as is EXCEPT </xmp>.
 
I just tried out the <xmp> tag and it works great. You should be aware, just so you know how it works, that <xmp> is a block level element. If you put this on your page:
Code:
<b>this is bold</b>
<xmp><b>this is bold</b></xmp>
<b>this is bold</b>
You will see this displayed:
Code:
[b]this is bold [/b]

<b>this is bold</b>

[b]this is bold[/b]
Note that even though there are no break tags in the html, there are not only breaks, but blank lines, before and after the <xmp> tags. You could get rid of the blank lines with css if needed.


Tracy Dryden

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard. [dragon]
 
You should also use a chart for "special and extended characters"...there may a clickable chart in your text-editor. Otherwise any decent HTML book will have one, although there are always a few characters left out.

That "xmp" tag is interesting...I haven't seen it before, but then I haven't bought an HTML book in the last year. Keep in mind, if this is a new or non-standards tag, some browsers may not understand it. This is why I recommend learning the special characters you use most often.

For example an ampersand ("&") followed by "lt" (less than) followed by a semicolon will give you the opening bracket, and using "gt" (greater than) instead of "lt" will give you the closing bracket. An ampersand followed by the word "copy" followed by a semicolon will give you the copyright symbol. Etc, etc.

Then you can use the "pre" tag surrounding your entire block of code...to make the font plain and monospaced. "Pre" has nothing to do with ignoring HTML code.
 
&lt; gives you <
&gt; gives you >
&copy; gives you the copyright symbol
 
Rather than being new, <xmp> is frightfully old and does not even appear in HTML4 doctype and has been deprecated since HTML3.2. That's why its use should not be encouraged, especially if you want to adhere to standards. I suppose using telbIT's solution is your best bet, or you could use a readonly textarea, which also provides that functionality.
 
telbIT said:
but then I haven't bought an HTML book in the last year

The last time I used <xmp> was about 3 years ago, so, it's far from new.
 
Thinking laterally, maybe you could render the typed code as a gif image, assuming you could position the resulting image in the right location on your page.

Regards, Andy.
**************************************
My pathetic attempts at learning HTML can be laughed at here:
 
Cumbersome, it's true, but as long as the browser in question is able to display images, there won't be an issue as to whether the code would display correctly.

Not intended to be a true solution, simply a different take on the problem. :)
Andy.

Regards, Andy.
**************************************
My pathetic attempts at learning HTML can be laughed at here:
 
I don't suppose the *&$#($ who developed the HTML 4 doctype gave you an alternative to a perfectly good tag that they capriciously decided to deprecate? I'm thinking that there is a committee that should be deprecated.

Tracy Dryden

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard. [dragon]
 
I agree. IMHO, <tt> should be deprecated. The idea is to create teletype or monospaced text. It could easily be done with CSS.

I think the readonly textarea is a great solution. However, you could also take the contents that should be left alone and copy-paste into a blank document. (It might be a good idea to replace all '&' characters with "&amp;" at this point.) You would then replace all '<' symbols with "&lt;" and all '>' symbols with "&gt;" . When you are finished, copy-paste the modifications and use <pre> .
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top