hi, is it possible to show code in html?
i thot it was with the <code></code> tag, but apparently that dosent work. any body know how to do it? i really dont want to have to use the & lt; and & gt; everytime. thanks.
hi, is it possible to show code in html?
i thot it was with the <code></code> tag, but apparently that dosent work. any body know how to do it? i really dont want to have to use the & lt; and & gt; everytime. thanks.
The following demo shows two possible methods. Both require you to use the & named entity to show other named entities but, the rest of the code is literal:
Code:<html> <head> <title>Show Code - Demo</title> </head> <body> <textarea cols="140" rows="3" readonly style="font-family:arial;overflow:hidden;border:none;white-space:wrap;"> Hi, &nbsp; <table><tr><td><a href="#">Top</a></td></tr></table><br>The quick gray fox jumped over the slow brown dog.<br>&nbsp;<p align="center">Sally sells seashells down by the seashore</p> </textarea> <br> <input type="text" readonly style="font-family:arial;border:none;" value="<br>&nbsp;<br>"> </body> </html>
- John________________________
Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate
Note, however, that as long as you have <> where they shouldn't be, whether it shows or not, the page won't be valid.
My advice is to just run the code through a text editor's "replace."
Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!
That's got to be high on my list of reasons to [expletive deleted] the validator. Utter nonsense if true.
- John________________________
Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate
Not really... you have to consider HTML's XML background. An XML parser doesn't care what the tag actually does in an HTML page: all it sees is one tag inside another.
Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!
Fortunately browsers are still being coded with more common sense in mind than that.
- John________________________
Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate
HTML has an SGML background, and as such it's slightly more forgiving than XML (and thus XHTML). The latter will not allow any literal occurances of < or & unless they begin an element or entity reference, respectively.Originally Posted by Twey
However, in this case, both SGML and XML require that < is escaped as < if followed immediately by a letter as that matches the grammar production for an opening tag. The content of a textarea element is described as PCDATA (parsed character data) and is sensitive to markup-like constructs.
They are being bloated with the code that is necessary to make them useful. That isn't a good thing in my opinion; it just encourages more junk. As Twey suggested, search and replace is your friend.Originally Posted by jscheuer1
Mike
Oops... beggin' yer pardon.Originally Posted by Mike
I agree, and so does the W3C; that's what XHTML is all about.Originally Posted by Mike
Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!
We'll probably never agree on this, I'm just happy to see Mike is back! I was worried about you, old friend.
Last edited by jscheuer1; 07-17-2005 at 10:38 AM.
- John________________________
Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate
thanks.
Bookmarks