473,756 Members | 9,646 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

proper and portable way to group elements

What's the right way to make sure checkboxes stick with their labels
when the window is resized?

Right now I'm trying <label><input ...text</labelwith
white-space:nowrap on label, but this only seems to work in Firefox and
IE 7.

In IE 8 and Opera I get one long line, as if the nowrap applied outside
the label elements.

In Safari for Windows, it groups the text with the checkbox on the right
instead of the left! That one I can't figure at all.

http://www.cs.northwestern.edu/~ries...ie-nowrap.html
Jun 27 '08 #1
7 2422
Chris Riesbeck wrote:
What's the right way to make sure checkboxes stick with their labels
when the window is resized?

Right now I'm trying <label><input ...text</labelwith
white-space:nowrap on label, but this only seems to work in Firefox and
IE 7.
<label><input ...>&nbsp;text</label>

?
Jun 27 '08 #2
Tue, 06 May 2008 15:30:48 -0500, /Chris Riesbeck/:
What's the right way to make sure checkboxes stick with their labels
when the window is resized?

Right now I'm trying <label><input ...text</labelwith
white-space:nowrap on label, but this only seems to work in Firefox and
IE 7.

In IE 8 and Opera I get one long line, as if the nowrap applied outside
the label elements.

In Safari for Windows, it groups the text with the checkbox on the right
instead of the left! That one I can't figure at all.

http://www.cs.northwestern.edu/~ries...ie-nowrap.html
In your actual source you have:

<label>
<input ...text
</label>

I've found if you put the closing </labeltag right after the text
it gets as expected:

<label>
<input ...text</label>

Probably bug in Opera but there may be another explanation.

--
Stanimir
Jun 27 '08 #3
Wed, 07 May 2008 02:53:41 +0300, /Stanimir Stamenkov/:
Tue, 06 May 2008 15:30:48 -0500, /Chris Riesbeck/:
>What's the right way to make sure checkboxes stick with their labels
when the window is resized?

Right now I'm trying <label><input ...text</labelwith
white-space:nowrap on label, but this only seems to work in Firefox
and IE 7.

In IE 8 and Opera I get one long line, as if the nowrap applied
outside the label elements.

In Safari for Windows, it groups the text with the checkbox on the
right instead of the left! That one I can't figure at all.

http://www.cs.northwestern.edu/~ries...ie-nowrap.html

In your actual source you have:

<label>
<input ...text
</label>

I've found if you put the closing </labeltag right after the text it
gets as expected:

<label>
<input ...text</label>

Probably bug in Opera but there may be another explanation.
Safari on Windows acts even more strange (with the original
example): it "groups" every check box with the text of the previous
label. Putting the closing </labelright after the text seems to
correct it with it, too. IE 6 seems o.k. in both cases.

--
Stanimir
Jun 27 '08 #4
Scripsit Chris Riesbeck:
What's the right way to make sure checkboxes stick with their labels
when the window is resized?
To put the checkbox and its label on a separate line with no other
content and to make the label as short as possible (but not shorter).
Under any normal circumstances, this removes the risk of line wrapping.
It is also an essential accessibility and usability feature. A user who
sees or hears
.... foo [ ] bar [ ] zap [ ] zip ...
may have difficulty in understanding whether he should click on the box
_before_ "bar" or _after_ "bar" when he wants to select "bar".
Admittedly, this might indicate slowness of understanding, or even
retardedness. Accessibility means, among other things, making pages
accessible to retarded people, too.
Right now I'm trying <label><input ...text</labelwith
white-space:nowrap on label, but this only seems to work in Firefox
and IE 7.
It's a technically correct way to prevent line breaks inside <label>
elements, but for some odd reason, line breaking control works oddly.
There are many ways to prevent line breaks in HTML documents, such as
the above CSS setting, the nowrap attribute for <tdelements, the
nonstandard but widely supported <nobrelement, the no-break space
character and other characters defined to be "non-breaking", including
special controls in Unicode. And the different ways work under different
conditions, with little logic. For a summary, check
http://www.cs.tut.fi/~jkorpela/html/nobr.html#prevent

I have yet to see a situation where <nobrdoes not work, but you might
have difficulties in explaining things to a pointy-haired boss who has
been commanded to require "standards compliance". So what _I_ would do -
if I really wanted to make the best effort to prevent a line break in
this case - is
<nobr><label><i nput ...>text</label></nobr>
In IE 8 and Opera I get one long line, as if the nowrap applied
outside the label elements.
Sounds like a refreshingly nasty bug. But IE 8 is beta test software, so
nobody should care what it does, except people devoted to testing the
software. (I'd love to test it, but why would I do that for free? It's
hard work.)
In Safari for Windows, it groups the text with the checkbox on the
right instead of the left! That one I can't figure at all.
Neither can I, but I think we can draw the conclusion that the approach,
though technically correct, just isn't feasible.
http://www.cs.northwestern.edu/~ries...ie-nowrap.html
IT'S BETTER NOT TO SHOUT. Text is more readable in mixed-case. If you
really love all-caps presentation, you could make the _content_
mixed-case and set text-transform: uppercase in CSS. This would imply
that by switching CSS support off, the user sees the content more
readably.

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

Jun 27 '08 #5
Harlan Messinger wrote:
Chris Riesbeck wrote:
>What's the right way to make sure checkboxes stick with their labels
when the window is resized?

Right now I'm trying <label><input ...text</labelwith
white-space:nowrap on label, but this only seems to work in Firefox
and IE 7.

<label><input ...>&nbsp;text</label>
I'd tried that also. It changed which browsers behaved well and which
badly but still didn't lead to the desired grouping over my test browsers.
Jun 27 '08 #6
Jukka K. Korpela wrote:
Scripsit Chris Riesbeck:
>What's the right way to make sure checkboxes stick with their labels
when the window is resized?

To put the checkbox and its label on a separate line with no other
content and to make the label as short as possible (but not shorter).
Indeed, it seems to be the internal line breaks that confused so many
browsers. Eliminating them, and simply setting white-space:nowrap on
LABEL fixed the problem in IE 7, IE 8, FF, Safari, and Opera. I.e., changing

<label>
<input type="checkbox" name="table" value="USER_ROL ES"USER_ROLES
</label>

to the following (each item on one line):

<label><input type="checkbox" name="table" value="USER_ROL ES">
USER_ROLES</label>
...

I have yet to see a situation where <nobrdoes not work, but you might
have difficulties in explaining things to a pointy-haired boss who has
been commanded to require "standards compliance". So what _I_ would do -
if I really wanted to make the best effort to prevent a line break in
this case - is
<nobr><label><i nput ...>text</label></nobr>
In one experiment, I used NOBR instead of LABEL and got the same varied
results. I didn't try NOBR + LABEL, but since LABEL + nowrap + no
internal line breaks works, I'll stick with that for now.
....But IE 8 is beta test software, so
nobody should care what it does, except people devoted to testing the
software. (I'd love to test it, but why would I do that for free? It's
hard work.)
I tried IE 8 to see if it fixed an unrelated bug I had in IE 7. (It did.)
>http://www.cs.northwestern.edu/~ries...ie-nowrap.html

IT'S BETTER NOT TO SHOUT. Text is more readable in mixed-case.
The demo page is a static copy of a JSP dump for developers of table
names in a database. Names are uppercase internally. The internal line
breaks were there to make the JSTL FOR-loop easier to read. Go know the
trouble that would cause.

Thanks, everyone.
Jun 27 '08 #7
Scripsit Chris Riesbeck:
Jukka K. Korpela wrote:
>Scripsit Chris Riesbeck:
>>What's the right way to make sure checkboxes stick with their labels
when the window is resized?

To put the checkbox and its label on a separate line with no other
content and to make the label as short as possible (but not shorter).

Indeed, it seems to be the internal line breaks that confused so many
browsers.
That's an interesting bug (by HTML specs, a line break is equivalent to
a space or, in some cases, ignored, but browsers are known to get this
wrong at times). However, my point was that the page should be designed
so that in the visual presentation, you have just the checkbox and its
label on one line, with no other content on that line and with no width
limitation except the natural canvas width. This generally removes the
line breaking problem in a puff of logic.
In one experiment, I used NOBR instead of LABEL
The NOBR markup is for preventing line breaks, not a replacement for any
other element, especially not for a logical element like LABEL.

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

Jun 27 '08 #8

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

Similar topics

1
1152
by: unishippers.suckfeed.newshosting.com | last post by:
Hi, I am wondering what is the best way to express a group of sub-elements not required to be in any order? so... <person> <height/> <weight/> </person>
14
2666
by: Viken Karaguesian | last post by:
Hello all, It stinks being a newbie! One thing that I'm not sure about with CSS is: where is the "proper" place to put font attibutes? This has me a little confused. Take the below style sheet (which is a work in progress) as an example. If I don't put the font attributes in the <body> <p> and <td> tags, the font will not appear the way I want (when I work in FrontPage, anyway). It doesn't seem to be enough to put the font attributes in...
10
2294
by: Peter Kirk | last post by:
Hi there can someone please help me with creating dynamic content in a table? For example, see the below javascript and html - why is a new row not created in the table when I click the button? (I am using Internet Explorer 6). <html> <head> <title>TEST</title> <script language="javascript">
5
2392
by: Kobu | last post by:
In embedded systems (programmed in C), often times structure declarations are used to group together several status/control/data registers of external hardware (or even internal registers). The example below (from GBD's THE C BOOK) uses this. Is this a portable method? . /*
10
2184
by: Jason Curl | last post by:
Dear C group, I'm very interested in writing portable C, but I only have GNU, Sparc and Cygwin to compile on. What I find is the biggest problem to writing portable C is what headers to include. What sites do people know about that are comprehensive in their differences? For example, MacOSX complained about <string.h>. With Solaris I needed
131
6204
by: pemo | last post by:
Is C really portable? And, apologies, but this is possibly a little OT? In c.l.c we often see 'not portable' comments, but I wonder just how portable C apps really are. I don't write portable C code - *not only* because, in a 'C sense', I
8
1831
by: ais523 | last post by:
I've checked the FAQ for this and couldn't find the answer. Is the following code snippet portable? int a; a=6; printf("%d\n",(*a)); This prints "6" on my compiler. I've been told it's always legal, but it seems slightly suspect to me. Can you really go out-of-bounds like this on one of the 'sub-arrays' a, a, etc.?
9
3423
by: uidzer0 | last post by:
Hey everyone, Taken the following code; is there a "proper" or dynamic way to allocate the length of line? #include <stdio.h> #include <errno.h> int main(int argc, char **argv) { FILE *fp;
409
11064
by: jacob navia | last post by:
I am trying to compile as much code in 64 bit mode as possible to test the 64 bit version of lcc-win. The problem appears now that size_t is now 64 bits. Fine. It has to be since there are objects that are more than 4GB long. The problem is, when you have in thousands of places
0
9482
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10062
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...
1
9878
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9728
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...
0
6551
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5167
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
5322
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3827
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
3392
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.