Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Preventing wrap on a short section of text

Status
Not open for further replies.

OsakaWebbie

Programmer
Feb 11, 2003
628
JP
I'm generating my HTML via a PHP query to a database, so I can't predict the content. I have a series of text pieces (the names of categories) that each have a checkbox, and are only separated by three spaces. There are many categories, so the whole thing will be multiple lines in a single (wide) cell of a table, but I don't want it to wrap in the middle of a category name (many of the categories are more than one word). Is there a way I can keep together the checkbox and the text that follows it, forcing line wraps to only be allowed (when necessary) between entries? Something like &quot;<nowrap><input...> A Category</nowrap>&quot;? (I know that particular tag doesn't exist, but perhaps the example will help you understand what I want.)
 
That's beautiful - just the sort of simple tag I was hoping existed. Sometimes it's hard to search for something unless you already know what it's called - all my search attempts about line wrapping turned up stuff about <td nowrap>, something I already know about and is unrelated to my problem.

But unlike a search engine, this forum has humans with brains! [sunshine]
 
One problem, nobr is not approved by the W3C.

But you could try something like this:

<span class=&quot;nobreak&quot;><input /> Category</span>

And then:

.nobreak { white-space: nowrap; }


É
::
 
Thanks for the warning. I will put your W3C-safe code in my notes file, and probably use it in my next iteration of this coding. Currently this DB interface is only for use by a very limited number of people, and for other reasons they will need to be (and are, anyway) using IE, which seems to respond to <nobr>, so for now I'll go with the adage, &quot;If it works, don't fix it.&quot;
 
It's true that <NOBR> is not an official W3C tag. According to it was introduced in Netscape 1.1 and picked up in version 2 of IE and Opera (and others).

This means that it is better supported than CSS, so you may be better sticking with it rather than going for the strict W3C approach which may actually work on fewer browsers.

If you're the type of person that wears belt and braces and carries string in your pocket, you could nest the <nobr> inside the <span> (or vice versa) like this:

<span class=&quot;nobreak&quot;><nobr>Sledgehammer and Nut</nobr></span>

That way you're covered for old browsers, which understand <nobr> but not CSS, and possible (though perhaps unlikely) future ones which comply rigidly to W3C standards but handle CSS. Personally I'm sticking with <nobr>! -- Chris Hunt
Extra Connections Ltd
 
i just wear skirts

[poke] [Hammer]
Nike Failed Slogans -- &quot;Just Don't Do It!&quot;
 
Even though female, I favor bluejeans and sweatshirts when society doesn't require me to wear something less comfortable. [shadeshappy] In regards to HTML, I am already married to CSS, Javascript, colored table borders, and probably several other browser-dependent things I'm not aware of, but since at least for the moment this database will not be for general consumption, it's probably not a problem. But it's good for me to know what's broad-based and what's not, as this is not the only web site I am doing or will do (I might even be targeting cell phones in the not-too-distant future!).
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top