Wrapping text between <xmp>

Discussion in 'HTML' started by Arnoud Oortwijk, Oct 23, 2003.

  1. suppose following code

    =========================

    <table border="1" width="256">

    <tr>

    <td width="256"> <xmp><script
    language="JavaScript">window.location="http://www.disney.com";</script></xmp
    >


    </td></tr>

    </table>

    =========================

    I want to show everything between <xmp> and </xmp> in other words I don't
    want the JavaScript to be executed. But I also want the table to be no wider
    than 256 and the text to be wrapped.

    How can this be done?

    All help will be greatly appreciated.

    Regards,

    Arnoud
    Arnoud Oortwijk, Oct 23, 2003
    #1
    1. Advertising

  2. Arnoud Oortwijk

    Steve Pugh Guest

    "Arnoud Oortwijk" <arnoudATgloriantDOTbe> wrote:

    >suppose following code


    I'd rather not...

    ><table border="1" width="256">
    ><tr>
    ><td width="256"> <xmp><script
    >language="JavaScript">window.location="http://www.disney.com";</script></xmp
    >>

    ></td></tr>
    ></table>


    Looks like you're using a table for layout. Don't.

    <xmp> was marked as obsolete in HTML 2.0 and doesn't exist at all in
    modern versions of HTML. You can not expect browsers to support <xmp>
    for ever. The code above doesn't stop Opera 7, for example, from
    parsing the JavaScript.

    >I want to show everything between <xmp> and </xmp> in other words I don't
    >want the JavaScript to be executed. But I also want the table to be no wider
    >than 256 and the text to be wrapped.
    >
    >How can this be done?


    <div style="width: 256px; border: 1px solid black; padding:
    0.5em;"><code>&lt;script language="JavaScript"&gt; window.location =
    "http://www.disney.com"; &lt;/script&gt;</code></div>

    Obviously you can move the styles into a stylesheet.

    The <code> element just marks this up as computer code - most browsers
    will display it in a monospaced font, but otherwise it will have no
    effect on rendering (so unlike with <xmp> or <pre> the text will
    wrap).

    Including a few spaces in the code will also help it to wrap better.

    Converting the < to &lt; makes them text and not the start of a tag.
    There's no actual need to convert > to &gt; in most cases (including
    this one) but it does no harm either and there may be browser bugs out
    there that make it better safe than sorry to do so.

    Steve

    --
    "My theories appal you, my heresies outrage you,
    I never answer letters and you don't like my tie." - The Doctor

    Steve Pugh <> <http://steve.pugh.net/>
    Steve Pugh, Oct 23, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. WJ

    XMP content and POST ?

    WJ, Mar 3, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    404
    Joerg Jooss
    Mar 5, 2005
  2. AspProgrammer

    xmp in asp or in asp.net

    AspProgrammer, May 9, 2005, in forum: XML
    Replies:
    1
    Views:
    445
    Martin Honnen
    May 10, 2005
  3. Davide

    Adobe XMP in Java

    Davide, May 23, 2006, in forum: Java
    Replies:
    0
    Views:
    565
    Davide
    May 23, 2006
  4. Ivan Herman

    XMP in Python

    Ivan Herman, May 28, 2004, in forum: Python
    Replies:
    0
    Views:
    417
    Ivan Herman
    May 28, 2004
  5. Grant Robertson

    Adobe's XMP as an open standard?

    Grant Robertson, Jan 7, 2007, in forum: XML
    Replies:
    1
    Views:
    418
    danja
    Jan 8, 2007
Loading...

Share This Page