Page 1 of 2 12 LastLast
Results 1 to 10 of 17

Thread: showing code?? without the &l; ...

  1. #1
    Join Date
    Dec 2004
    Posts
    157
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default showing code?? without the &l; ...

    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.

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    28,991
    Thanks
    43
    Thanked 3,198 Times in 3,160 Posts
    Blog Entries
    12

    Default

    The following demo shows two possible methods. Both require you to use the &amp; 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, &amp;nbsp; <table><tr><td><a href="#">Top</a></td></tr></table><br>The quick gray fox jumped over the slow brown dog.<br>&amp;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>&amp;nbsp;<br>">
    </body>
    </html>
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,878
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    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!

  4. #4
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    28,991
    Thanks
    43
    Thanked 3,198 Times in 3,160 Posts
    Blog Entries
    12

    Default

    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

  5. #5
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,878
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    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!

  6. #6
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    28,991
    Thanks
    43
    Thanked 3,198 Times in 3,160 Posts
    Blog Entries
    12

    Default

    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

  7. #7
    Join Date
    Dec 2004
    Location
    UK
    Posts
    2,358
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by Twey
    Not really... you have to consider HTML's XML background.
    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.

    However, in this case, both SGML and XML require that < is escaped as &lt; 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.

    Quote Originally Posted by jscheuer1
    Fortunately browsers are still being coded with more common sense in mind than that.
    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.

    Mike

  8. #8
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,878
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Quote Originally Posted by Mike
    HTML has an SGML background
    Oops... beggin' yer pardon.
    Quote Originally Posted by Mike
    That isn't a good thing in my opinion; it just encourages more junk.
    I agree, and so does the W3C; that's what XHTML is all about.
    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!

  9. #9
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    28,991
    Thanks
    43
    Thanked 3,198 Times in 3,160 Posts
    Blog Entries
    12

    Default

    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

  10. #10
    Join Date
    Dec 2004
    Posts
    157
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    thanks.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •