Go Back   Velocity Reviews > Newsgroups > HTML
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

HTML - Wrap long URL in table

 
Thread Tools Search this Thread
Old 09-21-2006, 05:22 PM   #1
Default Wrap long URL in table


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/NASAp...ng_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
  Reply With Quote
Old 09-21-2006, 08:01 PM   #2
Jim Moe
 
Posts: n/a
Default Re: Wrap long URL in table

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/NASAp...ng_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)
  Reply With Quote
Old 09-21-2006, 10:41 PM   #3
Jukka K. Korpela
 
Posts: n/a
Default Re: Wrap long URL in table

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/

  Reply With Quote
Old 09-22-2006, 12:02 PM   #4
Brian Cryer
 
Posts: n/a
Default Re: Wrap long URL in table

"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



  Reply With Quote
Old 09-22-2006, 02:50 PM   #5
Scott Gordo
 
Posts: n/a
Default Re: Wrap long URL in table


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

  Reply With Quote
Old 09-22-2006, 03:35 PM   #6
Jonathan N. Little
 
Posts: n/a
Default Re: Wrap long URL in table

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
  Reply With Quote
Old 09-22-2006, 05:32 PM   #7
Brian Cryer
 
Posts: n/a
Default Re: Wrap long URL in table


"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



  Reply With Quote
Old 09-22-2006, 06:30 PM   #8
Jonathan N. Little
 
Posts: n/a
Default Re: Wrap long URL in table

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
  Reply With Quote
Old 09-22-2006, 06:45 PM   #9
Spartanicus
 
Posts: n/a
Default Re: Wrap long URL in table

"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
  Reply With Quote
Old 09-22-2006, 10:42 PM   #10
Jukka K. Korpela
 
Posts: n/a
Default Re: Wrap long URL in table

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/

  Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump