Wrap long URL in table

Discussion in 'HTML' started by Scott Gordo, Sep 21, 2006.

  1. Scott Gordo

    Scott Gordo Guest

    I have an .aspx page that's pulling content from a SQL db.
    Sometimes users add long urls into a table/cell 400px wide. (Today's
    example was
    http://newyork.yankees.mlb.com/NASApp/mlb/nyy/ticketing/seating_pricing.jsp)
    This spreads the layout and messes up the spacing.
    I would tell the users to change their habits (insert text "click here"
    and assign the url to it) but it ain't gonna happen. I'm looking for a
    way to get the URL to wrap within the table.
    Any recommendations?
    TIA!

    Scott
     
    Scott Gordo, Sep 21, 2006
    #1
    1. Advertising

  2. Scott Gordo

    Jim Moe Guest

    Scott Gordo wrote:
    > I have an .aspx page that's pulling content from a SQL db.
    > Sometimes users add long urls into a table/cell 400px wide. (Today's
    > example was
    > http://newyork.yankees.mlb.com/NASApp/mlb/nyy/ticketing/seating_pricing.jsp)
    > This spreads the layout and messes up the spacing.
    > I would tell the users to change their habits (insert text "click here"
    > and assign the url to it) but it ain't gonna happen. I'm looking for a
    > way to get the URL to wrap within the table.
    > Any recommendations?
    >

    Do not use the URL as the displayed text. Pick something more meaningful
    and contextually pertinent, like "Yankess Seating Pricing", and put the
    URL in the <a> where it belongs.
    But since that "ain't gonna happen" (your visitors are highly
    inflexible) you are stuck with a deformed layout.
    Or you can add arbitrary spaces to the URL every nth character but then
    the URL text cannot be copied/pasted.

    --
    jmm (hyphen) list (at) sohnen-moe (dot) com
    (Remove .AXSPAMGN for email)
     
    Jim Moe, Sep 21, 2006
    #2
    1. Advertising

  3. Jim Moe wrote:

    > Do not use the URL as the displayed text.


    Agreed.

    > Or you can add arbitrary spaces to the URL every nth character but
    > then the URL text cannot be copied/pasted.


    No, that's a wrong approach. If you _really_ must put URLs as text on a web
    page, throw in some <wbr> tags after suitable characters, such as "?", "/",
    and "&". See
    http://www.cs.tut.fi/~jkorpela/html/nobr.html#suggest

    --
    Jukka K. Korpela ("Yucca")
    http://www.cs.tut.fi/~jkorpela/
     
    Jukka K. Korpela, Sep 21, 2006
    #3
  4. Scott Gordo

    Brian Cryer Guest

    "Jukka K. Korpela" <> wrote in message
    news:%FDQg.17342$...
    > Jim Moe wrote:
    >
    >> Do not use the URL as the displayed text.

    >
    > Agreed.
    >
    >> Or you can add arbitrary spaces to the URL every nth character but
    >> then the URL text cannot be copied/pasted.

    >
    > No, that's a wrong approach. If you _really_ must put URLs as text on a
    > web page, throw in some <wbr> tags after suitable characters, such as "?",
    > "/", and "&". See
    > http://www.cs.tut.fi/~jkorpela/html/nobr.html#suggest


    The <wbr> tag is great, widely supported but isn't in the w3c spec, so if
    you use it then your page won't validate. I know this because I used to make
    frequent use <wbr> until I got my fingers burnt over validation.

    As an alternative, why not use the word-wrap css, for example:

    <p style="width: 5em; word-wrap: break-word">12345678901234567890</p>

    should render as two or more lines (depending on your font settings). Of
    course to use this you have to know the maximum width you want - but the OP
    knew his width.
    --
    Brian Cryer
    www.cryer.co.uk/brian
     
    Brian Cryer, Sep 22, 2006
    #4
  5. Scott Gordo

    Scott Gordo Guest

    Brian Cryer wrote:
    > "Jukka K. Korpela" <> wrote in message
    > news:%FDQg.17342$...
    > > Jim Moe wrote:
    > >
    > >> Do not use the URL as the displayed text.

    > >
    > > Agreed.
    > >
    > >> Or you can add arbitrary spaces to the URL every nth character but
    > >> then the URL text cannot be copied/pasted.

    > >
    > > No, that's a wrong approach. If you _really_ must put URLs as text on a
    > > web page, throw in some <wbr> tags after suitable characters, such as "?",
    > > "/", and "&". See
    > > http://www.cs.tut.fi/~jkorpela/html/nobr.html#suggest

    >
    > The <wbr> tag is great, widely supported but isn't in the w3c spec, so if
    > you use it then your page won't validate. I know this because I used to make
    > frequent use <wbr> until I got my fingers burnt over validation.
    >
    > As an alternative, why not use the word-wrap css, for example:
    >
    > <p style="width: 5em; word-wrap: break-word">12345678901234567890</p>
    >
    > should render as two or more lines (depending on your font settings). Of
    > course to use this you have to know the maximum width you want - but the OP
    > knew his width.
    > --
    > Brian Cryer
    > www.cryer.co.uk/brian


    Thanks all. Now, instead of wrapping, I think that what I'm really
    looking for is what google did to my original post. After a certain
    number of characters, google automatically cut it off and inserted
    ellipses.There was maybe another ten characters it lopped off.
    I think I need a script that recognizes any code that starts with
    ">http://" and limits it to a certain number of characters (say 30)
    before cutting it off and inserting ellipses, while leaving the "<a
    href="http://" alone.
    Any ideas or leads?

    Scott
     
    Scott Gordo, Sep 22, 2006
    #5
  6. Brian Cryer wrote:
    <snip>

    > As an alternative, why not use the word-wrap css, for example:
    >
    > <p style="width: 5em; word-wrap: break-word">12345678901234567890</p>

    ^^^^^^^^^^^^^^^^^^^^^
    word-wrap? You won't find it here

    <http://www.w3.org/TR/CSS21/propidx.html>

    That is an MS thingy..... If OP really wants to force breaking lines
    intra-words of user input he needs to process server-side with some
    function that counts characters or looks for specific character to break
    on like '/' and insert BRs into the markup <= some maximum character
    length within the string....

    --
    Take care,

    Jonathan
    -------------------
    LITTLE WORKS STUDIO
    http://www.LittleWorksStudio.com
     
    Jonathan N. Little, Sep 22, 2006
    #6
  7. Scott Gordo

    Brian Cryer Guest

    "Jonathan N. Little" <> wrote in message
    news:8a9ad$4513f4bd$40cba77e$...
    > Brian Cryer wrote:
    > <snip>
    >
    >> As an alternative, why not use the word-wrap css, for example:
    >>
    >> <p style="width: 5em; word-wrap: break-word">12345678901234567890</p>

    > ^^^^^^^^^^^^^^^^^^^^^
    > word-wrap? You won't find it here
    >
    > <http://www.w3.org/TR/CSS21/propidx.html>
    >
    > That is an MS thingy..... If OP really wants to force breaking lines
    > intra-words of user input he needs to process server-side with some
    > function that counts characters or looks for specific character to break
    > on like '/' and insert BRs into the markup <= some maximum character
    > length within the string....


    The trouble with w3c is that they have too many working draft documents.
    Take a look at http://www.w3.org/TR/css3-text/, that's the document from
    which I learnt about word-wrap.
    --
    Brian Cryer
    www.cryer.co.uk/brian
     
    Brian Cryer, Sep 22, 2006
    #7
  8. Brian Cryer wrote:
    > "Jonathan N. Little" <> wrote in message
    > news:8a9ad$4513f4bd$40cba77e$...
    >> Brian Cryer wrote:
    >> <snip>
    >>
    >>> As an alternative, why not use the word-wrap css, for example:
    >>>
    >>> <p style="width: 5em; word-wrap: break-word">12345678901234567890</p>

    >> ^^^^^^^^^^^^^^^^^^^^^
    >> word-wrap? You won't find it here
    >>
    >> <http://www.w3.org/TR/CSS21/propidx.html>
    >>
    >> That is an MS thingy..... If OP really wants to force breaking lines
    >> intra-words of user input he needs to process server-side with some
    >> function that counts characters or looks for specific character to break
    >> on like '/' and insert BRs into the markup <= some maximum character
    >> length within the string....

    >
    > The trouble with w3c is that they have too many working draft documents.
    > Take a look at http://www.w3.org/TR/css3-text/, that's the document from
    > which I learnt about word-wrap.


    Agreed! But stick with CSS 2.1 Recommendation. Working draft are just
    that working drafts. You'll have enough trouble with CSS 2.1 and that
    pseudo-yet-all-too-popular browser that only spottily supports it!

    --
    Take care,

    Jonathan
    -------------------
    LITTLE WORKS STUDIO
    http://www.LittleWorksStudio.com
     
    Jonathan N. Little, Sep 22, 2006
    #8
  9. Scott Gordo

    Spartanicus Guest

    "Jonathan N. Little" <> wrote:

    >But stick with CSS 2.1 Recommendation.


    No such thing, the highest status CSS 2.1 achieved was Candidate
    Recommendation, but it has since been downgraded again to a Working
    Draft due to ridiculous W3C criteria.

    In this case that should not be seen as a reason not to use it as it is
    the best resource to use for practical CSS authoring, much better than
    the CSS 2.0 Rec.

    --
    Spartanicus
     
    Spartanicus, Sep 22, 2006
    #9
  10. Jonathan N. Little wrote:

    > But stick with CSS 2.1 Recommendation.


    It says: "This is a draft document and may be updated, replaced or obsoleted
    by other documents at any time. It is inappropriate to cite this document as
    other than work in progress."

    > Working draft are just that working drafts.


    Some working drafts are more working drafts than others. The CSS 2.1 draft
    is relatively close to what browsers do at best these days, whereas "CSS 3"
    is just a collection of sketches, ideas, and partly finalized drafts.

    Followups trimmed.

    --
    Jukka K. Korpela ("Yucca")
    http://www.cs.tut.fi/~jkorpela/
     
    Jukka K. Korpela, Sep 22, 2006
    #10
  11. Brian Cryer wrote:

    > The <wbr> tag is great, widely supported but isn't in the w3c spec,
    > so if you use it then your page won't validate.


    Who cares?

    > I know this because I
    > used to make frequent use <wbr> until I got my fingers burnt over
    > validation.


    You can stop playing with a validator then, or you can use a DTD that allows
    <wbr> (as explained on my page that I mentioned).

    > As an alternative, why not use the word-wrap css,


    Because it does something completely different and isn't consistently
    implemented (and isn't in any w3c spec).

    Breaking a URL at an arbitrary character is surely not desirable, or even
    acceptable.

    Followups trimmed - this is not about Dreamweaver.

    --
    Jukka K. Korpela ("Yucca")
    http://www.cs.tut.fi/~jkorpela/
     
    Jukka K. Korpela, Sep 22, 2006
    #11
    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. Simon
    Replies:
    26
    Views:
    14,465
    Simon
    Mar 24, 2006
  2. George Marsaglia

    Assigning unsigned long to unsigned long long

    George Marsaglia, Jul 8, 2003, in forum: C Programming
    Replies:
    1
    Views:
    755
    Eric Sosman
    Jul 8, 2003
  3. Aaron Fude

    To wrap or not to wrap?

    Aaron Fude, May 8, 2008, in forum: Java
    Replies:
    12
    Views:
    742
    Chronic Philharmonic
    May 10, 2008
  4. Art Werschulz

    Text::Wrap::wrap difference

    Art Werschulz, Sep 22, 2003, in forum: Perl Misc
    Replies:
    0
    Views:
    276
    Art Werschulz
    Sep 22, 2003
  5. Art Werschulz

    Text::Wrap::wrap difference

    Art Werschulz, Sep 24, 2003, in forum: Perl Misc
    Replies:
    1
    Views:
    281
    Anno Siegel
    Sep 25, 2003
Loading...

Share This Page