Discussion:
Stopping pathnames becoming split by wordwrapping in html
(too old to reply)
Mark Hobley
2010-03-22 22:25:06 UTC
Permalink
Is there an HTML tag that I can use to prevent pathnames from becoming split
by word wrapping? For example, supposing I have a document containing the
following text.

Do not wrap the /etc/foobar/foo.bar pathname!

Sometimes, the browser decided to split the line at one of the slash symbols,
rendering the line as follows:

Do not wrap the /etc/foobar/
foo.bar pathname!

I need /etc/foobar/foo.bar to always appear unbroken. Is there some tag I
could use here?, for example:

Do not wrap the <NOWRAP>/etc/foobar/foo.bar</NOWRAP> pathname!

I am not using style sheets, so an HTML tag solution is preferred here.

Mark.
--
Mark Hobley
Linux User: #370818 http://markhobley.yi.org/
Jukka K. Korpela
2010-03-23 20:39:36 UTC
Permalink
Post by Mark Hobley
Is there an HTML tag that I can use to prevent pathnames from
becoming split by word wrapping?
Yes, though it's not really _word_ wrapping you're worried about.
Post by Mark Hobley
I need /etc/foobar/foo.bar to always appear unbroken. Is there some
Do not wrap the <NOWRAP>/etc/foobar/foo.bar</NOWRAP> pathname!
It's the nobr markup you want:
<nobr>/etc/foobar/foo.bar</nobr>

More info: http://www.cs.tut.fi/~jkorpela/html/nobr.html
Post by Mark Hobley
I am not using style sheets, so an HTML tag solution is preferred here.
Not using style sheets in authoring? That's like not using computers these
days. :-)
--
Yucca, http://www.cs.tut.fi/~jkorpela/
Winston
2010-03-23 22:18:18 UTC
Permalink
Post by Mark Hobley
I need /etc/foobar/foo.bar to always appear unbroken. Is there some tag I
Do not wrap the <NOWRAP>/etc/foobar/foo.bar</NOWRAP> pathname!
* The <nowrap> tag is non-standard, but is supported by some browsers.

* The <nobr> tag is also non-standard, but is more widely supported.

* The table cell tags, <th> and <td>, have a "nowrap" attribute that *is*
standard, but tables cause line breaks unless you use CSS style to
prevent that, and if you're willing to have a line break, <br> is
simpler.

Note that specifying "don't wrap" inside a width=X region where X is "not
wide enough" may split things anyway (particularly if the nowrap item is
several whole lines long).

Other possibilities:
* use <br> just before the pathname;
* use <div style="display:inline-block">pathname</div>.
Post by Mark Hobley
Sometimes, the browser decided to split the line
If you're trying to solve the problem for a particular browser, you'll
need to say which one. :)

HTH,
-WBE
David Stone
2010-03-24 13:01:19 UTC
Permalink
Post by Winston
Post by Mark Hobley
I need /etc/foobar/foo.bar to always appear unbroken. Is there some tag I
Do not wrap the <NOWRAP>/etc/foobar/foo.bar</NOWRAP> pathname!
* The <nowrap> tag is non-standard, but is supported by some browsers.
* The <nobr> tag is also non-standard, but is more widely supported.
* The table cell tags, <th> and <td>, have a "nowrap" attribute that *is*
standard, but tables cause line breaks unless you use CSS style to
prevent that, and if you're willing to have a line break, <br> is
simpler.
Note that specifying "don't wrap" inside a width=X region where X is "not
wide enough" may split things anyway (particularly if the nowrap item is
several whole lines long).
* use <br> just before the pathname;
* use <div style="display:inline-block">pathname</div>.
Are there any pros/cons to using the above versus
<span style="white-space:nowrap">pathname</span>

(In my case, the pathname comes as part of a block of text, so
the span is contained in a p or div)
Winston
2010-03-24 14:13:11 UTC
Permalink
Post by David Stone
Are there any pros/cons to using the above versus
<span style="white-space:nowrap">pathname</span>
Well, I'm glad I took the time to check the CSS spec before replying... :)

One of the reasons I originally didn't suggest using span was because an
XHTML book I have (incorrectly, it would appear) says that "white-space"
can only be applied to block-level elements. A simple <span>, of course,
isn't a block-level element. However, the CSS2 spec at

http://www.w3.org/TR/CSS2/text.html#propdef-white-space

says that the white-space property applies to all elements. That being
the case, you're right, <span style="white-space:nowrap">pathname</span>
would be a standard-conforming way to specify nowrap.

However, the other reason I didn't suggest it was because the OP asked for
Post by David Stone
Post by Mark Hobley
Is there an HTML tag that I can use to prevent pathnames from becoming
split by word wrapping? [...] I am not using style sheets, so an
HTML tag solution is preferred here.
"not using style sheets" might not mean "not using CSS style at all", but
still, "white-space:nowrap" requires a browser that supports CSS.
-WBE
Jukka K. Korpela
2010-03-24 18:56:33 UTC
Permalink
Post by Winston
* The <nowrap> tag is non-standard, but is supported by some browsers.
Can you mention one?
Post by Winston
* The <nobr> tag is also non-standard, but is more widely supported.
That's an understatement. Can you mention a browser that does _not_ support
it?

(I can, but to prevent spoiling, I'll rot-13 my answer:
Vg vf n tbbq byq grkg pryy oebjfre anzrq nsgre n sryvar.)
--
Yucca, http://www.cs.tut.fi/~jkorpela/
Winston
2010-03-25 06:46:14 UTC
Permalink
Post by Jukka K. Korpela
Post by Winston
* The <nowrap> tag is non-standard, but is supported by some browsers.
Can you mention one?
I thought I could, but attempts to verify my recollection failed. I saw
web pages using <nowrap> back in 1999, and I recall being surprised that
such a tag would exist since nowrap was normally an attribute, but after
the browser feature wars, not-in-the-standards tags and attributes didn't
mean they didn't exist. :-/

So, another answer for the OP is that many browsers support NOWRAP as an
attribute in a variety of tags (e.g., <p nowrap>), though it's
non-standard except in <th> and <td>.
Post by Jukka K. Korpela
Post by Winston
* The <nobr> tag is also non-standard, but is more widely supported.
That's an understatement. Can you mention a browser that does _not_
support it?
There are some ancient and/or text-only browsers. I don't actually know
for sure about Emacs+w3 or Lynx, but, yes, I still use Lynx once in a
while. :)
-WBE

David E. Ross
2010-03-23 22:27:07 UTC
Permalink
Post by Mark Hobley
Is there an HTML tag that I can use to prevent pathnames from becoming split
by word wrapping? For example, supposing I have a document containing the
following text.
Do not wrap the /etc/foobar/foo.bar pathname!
Sometimes, the browser decided to split the line at one of the slash symbols,
Do not wrap the /etc/foobar/
foo.bar pathname!
I need /etc/foobar/foo.bar to always appear unbroken. Is there some tag I
Do not wrap the <NOWRAP>/etc/foobar/foo.bar</NOWRAP> pathname!
I am not using style sheets, so an HTML tag solution is preferred here.
Mark.
As already noted, neither <nowrap> nor <nobr> are valid HTML 4.01.
Thus, some browsers will not recognize these.

My recommendation would be to allow the path to wrap. Just bracket it
as if it were a URI, per Appendix C of RFC 3986. Users who understand
what is a path should also understand the bracketing.
--
David E. Ross
<http://www.rossde.com/>.

Anyone who thinks government owns a monopoly on inefficient, obstructive
bureaucracy has obviously never worked for a large corporation. © 1997
dorayme
2010-03-24 07:50:14 UTC
Permalink
Post by David E. Ross
Post by Mark Hobley
Is there an HTML tag that I can use to prevent pathnames from becoming split
by word wrapping? For example, supposing I have a document containing the
following text.
Do not wrap the /etc/foobar/foo.bar pathname!
Sometimes, the browser decided to split the line at one of the slash symbols,
Do not wrap the /etc/foobar/
foo.bar pathname!
I need /etc/foobar/foo.bar to always appear unbroken. Is there some tag I
Do not wrap the <NOWRAP>/etc/foobar/foo.bar</NOWRAP> pathname!
I am not using style sheets, so an HTML tag solution is preferred here.
Mark.
As already noted, neither <nowrap> nor <nobr> are valid HTML 4.01.
Thus, some browsers will not recognize these.
My recommendation would be to allow the path to wrap. Just bracket it
as if it were a URI, per Appendix C of RFC 3986. Users who understand
what is a path should also understand the bracketing.
Or perhaps put it in an element styled to em width to handle it.
Depends on what the context is whether this is reasonable.
--
dorayme
Jukka K. Korpela
2010-03-24 19:06:15 UTC
Permalink
Post by David E. Ross
As already noted, neither <nowrap> nor <nobr> are valid HTML 4.01.
So what?
Post by David E. Ross
Thus, some browsers will not recognize these.
The fictional <nowrap> can be ignored, but <nobr> is much better supported
than many features that are valid HTML 4.01. Besides, if a browser does not
recognize the <nobr> markup, you don't lose anything as compared with not
using it.

Of course you can use the clumsier CSS approach and be proud of being valid,
but why would you use a less reliable method just to conform to some rather
arbitrary syntax definition? Breaking a line can make a _semantic_
difference. Consider the statement "Use the command rm foo/*". If a line
break is entered after the "/", the meaning is changed to "Use the command
rm foo / *" (which deletes all files).
Post by David E. Ross
My recommendation would be to allow the path to wrap. Just bracket it
as if it were a URI, per Appendix C of RFC 3986. Users who understand
what is a path should also understand the bracketing.
Delimiters can be useful, but that's a different issue.

Appendix C prohibits breaking a line inside a URL after a hyphen "-"
character. How would you deal with that issue in your approach?

Besides, the original question mentioned pathnames like /etc/foobar/foo.bar.
While they could be part of a URL, the example looks suspiciously like a
UNIX pathname, which has nothing to do with URLs.
--
Yucca, http://www.cs.tut.fi/~jkorpela/
David E. Ross
2010-03-24 23:07:40 UTC
Permalink
Post by Jukka K. Korpela
Post by David E. Ross
As already noted, neither <nowrap> nor <nobr> are valid HTML 4.01.
So what?
Post by David E. Ross
Thus, some browsers will not recognize these.
The fictional <nowrap> can be ignored, but <nobr> is much better supported
than many features that are valid HTML 4.01. Besides, if a browser does not
recognize the <nobr> markup, you don't lose anything as compared with not
using it.
Of course you can use the clumsier CSS approach and be proud of being valid,
but why would you use a less reliable method just to conform to some rather
arbitrary syntax definition? Breaking a line can make a _semantic_
difference. Consider the statement "Use the command rm foo/*". If a line
break is entered after the "/", the meaning is changed to "Use the command
rm foo / *" (which deletes all files).
Post by David E. Ross
My recommendation would be to allow the path to wrap. Just bracket it
as if it were a URI, per Appendix C of RFC 3986. Users who understand
what is a path should also understand the bracketing.
Delimiters can be useful, but that's a different issue.
Appendix C prohibits breaking a line inside a URL after a hyphen "-"
character. How would you deal with that issue in your approach?
Besides, the original question mentioned pathnames like /etc/foobar/foo.bar.
While they could be part of a URL, the example looks suspiciously like a
UNIX pathname, which has nothing to do with URLs.
I said "as if it were a URI" not "because it's a URI". I often bracket
non-URI paths.
--
David E. Ross
<http://www.rossde.com/>.

Anyone who thinks government owns a monopoly on inefficient, obstructive
bureaucracy has obviously never worked for a large corporation. © 1997
Loading...