Wrap long URL in table

S

Scott Gordo

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
 
J

Jim Moe

Scott said:
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.
 
B

Brian Cryer

Jukka K. Korpela said:
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.
 
S

Scott Gordo

Brian said:
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.

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
 
J

Jonathan N. Little

Brian Cryer wrote:
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....
 
B

Brian Cryer

Jonathan N. Little said:
Brian Cryer wrote:

^^^^^^^^^^^^^^^^^^^^^
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.
 
J

Jonathan N. Little

Brian said:
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!
 
S

Spartanicus

Jonathan N. Little said:
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.
 
J

Jukka K. Korpela

Jonathan said:
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.
 
J

Jukka K. Korpela

Brian said:
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
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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,781
Messages
2,569,619
Members
45,308
Latest member
Foster Bronson

Latest Threads

Top