473,661 Members | 2,484 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to break long URL's?

Hi,

I'm currently having a problem where a long URL or a line of text with
no spaces will break the design of a webpage, http://
blog.seoptimise .com/2007/01/how-to-add-delicious-and-digg-blog-
rss.html is an example of this.

Does anyone know if it's possible to break this text into multiple
lines using CSS?

Thanks in advance,
Kev

Feb 15 '07 #1
17 21322
On 15 Feb, 07:06, "kevgibbo" <kevgi...@gmail .comwrote:
I'm currently having a problem where a long URL or a line of text with
no spaces will break the design of a webpage,
Why is a URL visible to the design of a web page? In most cases, the
URL should be in a href but there's no reason to use it as the visible
link text.

If it is deliberately visible (and there are good reasons to), then
just place it on its own line and give it some distinctive and
smallish font. For URLs of the moderate size you describe, then it's
no problem to fit them on a single line, so long as they start from
the beginning of it.

Huge URLs are a bad idea, usually unnecessary and should ideally be
avoided at source by just not needing them to be so long.
Does anyone know if it's possible to break this text into multiple
lines using CSS?
I'd embed <brand I'd do it by hand. The useful contexts for doing
this are few and really only within "tutorials" and meta-pages about
the web itself. For anything else, then embed the link rather than
stating it visibly.

(Copying URLs for airline booking sites so that you can email them to
your partner to book holidays! Aargh!)
Feb 15 '07 #2
Scripsit kevgibbo:
I'm currently having a problem where a long URL or a line of text with
no spaces will break the design of a webpage, http://
blog.seoptimise .com/2007/01/how-to-add-delicious-and-digg-blog-
rss.html is an example of this.
Most importantly, don't put URLs into the _content_ proper, only into
attribute values (such as href="...") where long URLs won't hurt.

Roughly speaking, URLs should appear in the content proper only when a page
_discusses URLs_. For example, if you wish to write a page how to refer to
some documents by their URLs in web authoring or in email messages or print
media, you may need some sample URLs, which might be rather long. Then the
prime problem is to _prevent_ browsers from breaking them!

The point is that a long URL usually doesn't hurt in the content unless it
appears in the middle of a text paragraph, where it should not appear, or
you have a rigid page layout, which you should not have.

But it _is_ harmful is a browser breaks a URL after a hyphen "-", as it may
well do. How will the reader know or guess whether the hyphen is part of the
URL or just introduced by hyphenation in word breaking? (Admittedly,
experienced users know that browsers don't hyphenate. But not all users are
experienced. Besides, very experienced users know that browsers may
hyphenate - when a hyphenation hint has been given using the soft hyphen.)
Does anyone know if it's possible to break this text into multiple
lines using CSS?
If you do need to include long URLs into the text of a document, wrap them
inside <nobr>...</nobrmarkup. You may add <wbrtags after points where a
line break is allowed, but then you should use some delimiters or otherwise
make it clear to the user what constitutes the URL. That's the practical
way, and you just have to tolerate people who (correctly) scream
"nonstandar d markup!". CSS could in principle be used for preventing breaks,
since
<nobr>foo</nobr>
effectively corresponds to
<span style="white-space: nowrap">foo</span>
but I don't see much point there. I don't really want to use more
complicated code when nothing else is gained in practice than the risk that
my URLs are broken when CSS is off. So this is a job for HTML, not CSS.

In the CSS 3 drafts, there's the word-wrap property that could be used to
suggest that _any_ line break is allowed in a string, using word-wrap:
break-word. IE supports this. But it's really something to be avoided. It
would violate common sense, readability, and several standards and
recommendations to break a URL _arbitrarily_.

More info: http://www.cs.tut.fi/~jkorpela/html/nobr.html

--
Jukka K. Korpela ("Yucca")
http://www.cs.tut.fi/~jkorpela/

Feb 15 '07 #3
On Feb 15, 2:06 am, "kevgibbo" <kevgi...@gmail .comwrote:
I'm currently having a problem where a long URL or a line of text with
no spaces will break the design of a webpage, http://
blog.seoptimise .com/2007/01/how-to-add-delicious-and-digg-blog-
rss.html is an example of this.
I'm not saying you *should* do this, as the other folks to reply have
pointed out reasons not to. But I have a couple of suggestions if you
want a wrappable URL (or other rediculously long "word" or content
with no spaces). Instead of inserting hyphens, how about the zero-
width non-joiner? (&zwnj;) Or, you could insert spaces, and class
the anchor or a span element "collapsespaces " and then use the
following CSS:

..collapsespace s {
word-spacing: -.33em;
}

Semantically, the spaces are still there, which is why zwnj is
probably a better idea. Also, you might have to tweak the specified
value depending on the font you're using, but most fonts' space
character has an advance width of very close to 1/3 EM.

I agree with the others who have replied to this thread that, in most
cases, a long URL should not appear in content. But I can imagine a
few situations when it might be of use, possibly even in a narrow but
still variable-width column of text that needs to stay narrow. Or
perhaps it's not a URL but a very long (possibly invented) word, or a
string of some specialized notation where spaces are sparse. It's for
these situations that my advice is intended.

--
Vid the Kid

Feb 15 '07 #4
Thanks for all of your help, I noticed this page has broke the URL
that I posted and seem to have done this using nowrap within the
stylesheet and inside <tdtags. Is this a good way to do it?

Cheers,
Kev
www.seoptimise.com

Feb 15 '07 #5
In article
<11************ **********@v33g 2000cwv.googleg roups.com>,
"kevgibbo" <ke******@gmail .comwrote:
Thanks for all of your help, I noticed this page has broke the URL
that I posted and seem to have done this using nowrap within the
stylesheet and inside <tdtags. Is this a good way to do it?
Its a different problem in email and newsgroup posts, best to
wrap urls in <in these cases...

--
dorayme
Feb 15 '07 #6
dorayme <do************ @optusnet.com.a uwrote in news:doraymeRid This-
86************* ******@news-vip.optusnet.co m.au:
Its a different problem in email and newsgroup posts, best to
wrap urls in <in these cases...
OT alert:
For these situations I use tinyurl:

http://tinyurl.com/

(there's a tinyurl creator addon for FireFox: rightclick any page and
choose 'create tinyurl' to copy the created url to your clipboard)

Feb 15 '07 #7
Dirk wrote on 15 feb 2007 in comp.infosystem s.www.authoring.stylesheets:
dorayme <do************ @optusnet.com.a uwrote in news:doraymeRid This-
86************* ******@news-vip.optusnet.co m.au:
>Its a different problem in email and newsgroup posts, best to
wrap urls in <in these cases...

OT alert:
For these situations I use tinyurl:

http://tinyurl.com/

(there's a tinyurl creator addon for FireFox: rightclick any page and
choose 'create tinyurl' to copy the created url to your clipboard)
... or make a IE favelet called tiny.url:

[InternetShortcu t]
URL=javascript: void(location.h ref='http://tinyurl.com/create.php?
url='+location. href)

[on one line!]

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Feb 15 '07 #8
Scripsit Vid the Kid:
But I have a couple of suggestions if you
want a wrappable URL (or other rediculously long "word" or content
with no spaces). Instead of inserting hyphens, how about the zero-
width non-joiner? (&zwnj;)
Did _you_ actually try it? By definition, the zero width non-joiner prevents
joining and ligature behavior. It's not meant for line breaking control. It
is (by Unicode) in line breaking class CM, which pretty much means that it
is ignored in line breaking. Technically it _prevents_ line breaks in
certain contexts. Modern browsers seem to treat it that way. Older browser
may get wild, since they might not know about this character and might try
to display it and end up with displaying a symbol for a missing character.
Or, you could insert spaces,
A space within a URL is simply an error.
and class
the anchor or a span element "collapsespaces " and then use the
following CSS:

.collapsespaces {
word-spacing: -.33em;
}
And stay tuned to unpredictable results, since you cannot _know_ the width
of a space. Besides, the page would have a normal space when CSS is off.
Semantically, the spaces are still there, which is why zwnj is
probably a better idea.
Sorry, but they are both completely wrong ideas.
most fonts' space
character has an advance width of very close to 1/3 EM.
Little does it help to think that way, if the rendering is all messed up
when your guess is wrong.

Besides, your guess is _generally_ wrong. In the average, a space is 1/4 em
(.25em) wide. See e.g.
http://www.microsoft.com/typography/...ec/spaces.aspx
(or do some testing, using different fonts).

--
Jukka K. Korpela ("Yucca")
http://www.cs.tut.fi/~jkorpela/

Feb 15 '07 #9
Thu, 15 Feb 2007 15:39:56 +0200 from Jukka K. Korpela
<jk******@cs.tu t.fi>:
Most importantly, don't put URLs into the _content_ proper, only into
attribute values (such as href="...") where long URLs won't hurt.
The problem with that is when the user prints a document, the printed
copy has no indication what the URL is. (Lynx offers an option to do
it as a set of endnotes, but I don't know of another browser that
does.) Sometimes that doesn't matter, sometimes it does.

--
Stan Brown, Oak Road Systems, Tompkins County, New York, USA
http://OakRoadSystems.com/
HTML 4.01 spec: http://www.w3.org/TR/html401/
validator: http://validator.w3.org/
CSS 2.1 spec: http://www.w3.org/TR/CSS21/
validator: http://jigsaw.w3.org/css-validator/
Why We Won't Help You:
http://diveintomark.org/archives/200..._wont_help_you
Feb 16 '07 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
2381
by: dr. zoidberg | last post by:
Hello, I have small BB and when someone post long URL it breaks complete forum. Is there anything I can do. TNX
2
3143
by: SMichal | last post by:
Hi, how can I read this link with parameters from web.config ? There's syntax error when I try to define it in web.config. http://dotnet1/carspecs/options.asp?language_id=3&specsdb=SSCD_CS2002&target_currencies=EUR&projectdb=carspecs_PROJECT&screen=options&category=O&init="
5
10140
by: dubing | last post by:
Hi, We have some html source like this: <div class="survey"> <form action="students/cbe-graduate-students/survey.html" method="post" id="frmPbSurvey"> <fieldset class="survey_item"> <legend class="question"><span class="questionNumber">6.</span>If the
3
8798
by: chico | last post by:
Hello, I hope you can help me on this one. I would like to have an iFrame pointing to dynamic url that gets parameters, for example: iframe .... src="blabla?myparm1=par1&myparam2=par2.... , The problem with this method, is that when the src url is too long (over 2400 characters) then the IE will not read it correctly.
3
1479
by: John Nagle | last post by:
Here's a hostile URL that "urlparse.urlparse" seems to have mis-parsed. ====...
11
3680
by: joe | last post by:
Hello anyone knows how to write a funtion to genereate a tiny url with letters and numbers only. Something almost always unique. THanks.
1
3570
by: miraan | last post by:
Hi, I have searched on the internet but can't find a way to disguise a long ugly php url such as www.domain.com/companies.php?id=543 into this: www.domain.com/companyname the folder "companyname" shouldnt really exist. There should be some instructions in .htaccess or something like that (not sure) to show www.domain.com/companies.php?id=543 instead but still keep www.domain.com/companyname in the address bar. I dont want to actually create a...
1
1703
by: markalanbaker | last post by:
I have a site that is using parse_url in this command: <?php $domain = parse_url($row, PHP_URL_HOST); ?> buyfrom is a url and in this case the specific url I having difficulty with is very long: ...
0
8343
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8856
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8633
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6185
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4179
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4347
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2762
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1992
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1747
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.