10 replies [Last post]
Ryyo
Offline
Regular
East Lansing MI
Last seen: 18 years 4 weeks ago
East Lansing MI
Joined: 2003-04-16
Posts: 13
Points: 0

Howdy all,

I dont know if this really falls into the relm of CSS or not, but I was wondering if there is some sort of tag that diables html, much like the button in a forum poster... I want to be able to put raw html code on a couple of pages I have, so people can look at examples.

Previsously I have done this using periods in between tags to confuse html, but this seems like a really cumbersome way to execute it, and hampers copy and paste. If anyone has some clues for me, that would be great!

Thanks for your time,

Ryyo

Tony
Tony's picture
Offline
Moderator
Brisbane
Last seen: 1 week 6 days ago
Brisbane
Timezone: GMT+10
Joined: 2003-03-12
Posts: 5343
Points: 2964

html characters

Hi Ryyo,
What you should try is to use html characters & lt; four characters without space to give & and & gt; for &.

Then you can put what you want between them eg : &div&

You can then wrap them in a code tag and use css to style them slightle different from the rext of the text: <code style="background-color:#CCCCCC">

dJomp
dJomp's picture
Offline
Enthusiast
Last seen: 5 years 15 weeks ago
Joined: 2003-03-23
Posts: 422
Points: 0

Disabling HTML so one can display code examples

I don't think that post came out quite as Tony was expecting! (At least, not with my character set...)

Note the following should be written without the spaces.

& l t ; will give < [ less than ]
& g t ; will give > [ greater than ]

So & l t ; div & r t ; will appear as <div> (or similar)

Hopefully you've got a nice editor with a find-replace type function, to make changing all the tags a lot easier...

You know you're a geek when you try to shoo a fly away from the monitor with your cursor.

Tony
Tony's picture
Offline
Moderator
Brisbane
Last seen: 1 week 6 days ago
Brisbane
Timezone: GMT+10
Joined: 2003-03-12
Posts: 5343
Points: 2964

Disabling HTML so one can display code examples

Thanks DJomp,
It looked fine while previewing :?

Ryyo
Offline
Regular
East Lansing MI
Last seen: 18 years 4 weeks ago
East Lansing MI
Joined: 2003-04-16
Posts: 13
Points: 0

Disabling HTML so one can display code examples

Ahhh, I see now. Yeah, that first post really sent me reeling!

I cant seem to get it right yet however, this is what I have as of now:

<a href="URL">LINKNAME</a>

And this is how it is displaying in my browser. I assume this is the same substitution technique as %20 for spaces and what not?

Ryyo

EDIT: Ha ha, I guess it DOES work. Guess there is something squirly with my browser.... I'm using IE6 though, and it shows up alright on this page.... Could it be my web hoster or something?

Anonymous
Anonymous's picture
Guru

Disabling HTML so one can display code examples

Try the <pre></pre> tags.

Sven
Sven's picture
Offline
Enthusiast
Brisbane, Australia
Last seen: 13 years 49 weeks ago
Brisbane, Australia
Timezone: GMT+10
Joined: 2003-03-12
Posts: 166
Points: 0

Disabling HTML so one can display code examples

Unfortunately, the pre tags will maintain formatting, but still cause enclosed HTML tags to be interpreted. Nice approach though!

Ryyo, how did you end up going with this stuff?

Anonymous
Anonymous's picture
Guru

Disabling HTML so one can display code examples

hm, hey, you're right.=p in that case, try http://www.w3.org/TR/REC-html40/sgml/entities.html

Anonymous
Anonymous's picture
Guru

Disabling HTML so one can display code examples

Use <xmp></xmp> tags around the HTML. This has always worked for me.

Regards
Martin Burford
Senior Web Developer

dietstatedotcom
Offline
newbie
Last seen: 11 years 51 weeks ago
Joined: 2009-05-22
Posts: 1
Points: 0

Disabling HTML so one can display code examples

I've always used just like the previous guy. It does works fine

gary.turner
gary.turner's picture
Offline
Moderator
Dallas
Last seen: 10 weeks 5 days ago
Dallas
Timezone: GMT-6
Joined: 2004-06-25
Posts: 9776
Points: 3858

Just to set things straight

Just to set things straight since the thread has been resurrected; the xmp element was deprecated in html3.2, Jan, 1997, and is completely gone from html4.0, Dec, 1999.

Don't use it.

gary

If your web page is as clever as you can make it, it's probably too clever for you to debug or maintain.