473,378 Members | 1,478 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

usage of   to keep input and label together

Hallo,

In a form I have several text or checkbox inputs with their
appropriate labels. I'd like to keep label and input together, so I
connect them with a  , like:
<input type="checkbox" name="h" value="1" id="chk"/>&nbsp;<label
for="chk">Schreibweisentolerant</label>

Apparently this doesn't work in Firefox 2. It works in IExplorer and
Opera. As well I tried:
<input type="checkbox" name="h" value="1" id="chk"/><label
for="chk">&nbsp;Schreibweisentolerant</label>

Somehow Firefox seems to think that he can break anyway between tags.
If I placed another &nbsp; within the word "Schreibweisentolerant"...

<input type="checkbox" name="h" value="1" id="chk"/><label
for="chk">&nbsp;Schreibweisen&nbsp;tolerant</label>

....Firefox would keep the two parts of the word together.

Is there any way to correct this?

Best regards,

Christian Kirchhoff

Feb 12 '07 #1
4 17830
Scripsit ck******@directmedia.de:
In a form I have several text or checkbox inputs with their
appropriate labels. I'd like to keep label and input together,
Fine, but that's usually a non-issue. It becomes a problem if you make it a
problem by trying to squeeze the content into some smallish fixed-width or
otherwise narrow area. Usually the best fix is to stop creating such
problems. Normally a form should take all the available width and should
contain a single input item (an input field and the associated label) on one
line.
<input type="checkbox" name="h" value="1" id="chk"/><label
for="chk">&nbsp;Schreibweisentolerant</label>

Somehow Firefox seems to think that he can break anyway between tags.
I'd rather say that it treats the checkbox element as a special element
rather than comparable to a letter.
Is there any way to correct this?
As I wrote above, remove the techniques you use to "force" the data into a
narrow area, and the problem vanishes in a puff of smoke.

But technically, you can force Firefox to keep the checkbox and its label on
the same line by wrapping them inside a <divelement and setting
white-space: nowrap for it. Contrary to its name, the white-space property
affects line breaks in general, and the value nowrap forbids all line breaks
except those explicitly indicated by the use of <bror comparable
constructs.

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

Feb 12 '07 #2
Thanks for the answer. I am not responsible for the html text of the
page, I just take care of the CSS. And if the html code is build in a
way that more than one input field is in one line of the form, then
that's the way it is and there is no use for me to discuss about it.

Even if there is only one input per line, e.g.:
<label>Volltextsuche
<input type="text" name="e" value="a" size="30" />
</label>

If the user narrows the width of the browser window to a certain
extent, the input text field breaks into a second line. With my
question I was just wondering if it is possible to keep an input
element and it's label text together with &nbsp;, no matter whether
there are several input elements in one line or just one.

Because IExplorer seems to do that but Firefox not.

I'll keep the alternative with div and white-space: nowrap in mind,
thanks very much.

best regards,

Christian Kirchhoff

Feb 14 '07 #3
Scripsit ck******@directmedia.de:
Thanks for the answer.
Please learn to quote the relevant part of the message you are commenting
on. Try googling for e.g. "wie zitiere ich im usenet".
I am not responsible for the html text of the
page, I just take care of the CSS.
When the HTML needs fixing, the person responsible for the CSS part shall
report the need.

By the way, do you realize that you are now trying to restrict the scope of
discussion to CSS and exclude HTML considerations, despite the fact that you
had decided to post to a group that specifically deals with HTML, not CSS?
And if the html code is build in a
way that more than one input field is in one line of the form, then
that's the way it is and there is no use for me to discuss about it.
If someone wants to keep poorly designed HTML (did you actually _check_
this?), then he should deal with the consequences as well. He won't know
about the consequences unless someone tells him.
Even if there is only one input per line, e.g.:
<label>Volltextsuche
<input type="text" name="e" value="a" size="30" />
</label>

If the user narrows the width of the browser window to a certain
extent, the input text field breaks into a second line.
That's what _should_ happen, too. It would be foolish to force the label and
the input field to appear on the same line at the cost of forcing the user
to scroll if he wants to see all of the input box.

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

Feb 14 '07 #4
On 02/14/2007 10:05 AM, ck******@directmedia.de wrote:
Thanks for the answer. I am not responsible for the html text of the
page, I just take care of the CSS. And if the html code is build in a
way that more than one input field is in one line of the form, then
that's the way it is and there is no use for me to discuss about it.

Even if there is only one input per line, e.g.:
<label>Volltextsuche
<input type="text" name="e" value="a" size="30" />
</label>

If the user narrows the width of the browser window to a certain
extent, the input text field breaks into a second line. [...]
Not if you place a style of "white-space: nowrap" on label elements:

label {
white-space: nowrap;
}
--
Windows Vista and your freedom in conflict:
http://techdirt.com/articles/20061019/102225.shtml
Feb 14 '07 #5

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

Similar topics

12
by: Tjerk Wolterink | last post by:
In XHTML the entity nbsp stands for   A normal space like " " is also displayed as an normal space, but multiple spaces like " " are interpreted as 1 space in the xhtml page. So there comes...
2
by: Rob T | last post by:
I have a dropdown list that I would like to put in a bunch of &nbsp;'s into it (I'm setting the font to a monospace font so I can show a couple of columns nice and neat). In the old asp days, I...
1
by: Vikram | last post by:
i am adding a row in dataset , in which i want to add &nbsp; (space chracter for html) and then want to bind dataset to asp.net dropdown list box. But & automatically converted to &amp chracter....
9
by: Jouni Karppinen | last post by:
I create a HTMLTable in my C# code and then add rows and cells into that table. I'm trying to set top and bottom border for each cell by using stylesheet and it works as far as cell has some text...
3
by: yawnmoth | last post by:
<? echo 'a'.trim(html_entity_decode('&nbsp;a&nbsp;')).'a'; ?> Shouldn't PHP output aaa? Looking at the documentation for trim I see that it doesn't support chr(0xA0) (eg....
28
by: entfred | last post by:
I have the following line of html: &nbsp;&nbsp1234&nbsp;&nbsp;&nbsp;&nbsp;&nbspabc&nbsp;&nbsp;&nbspyow In Internet Explorer 6.0, the columns look ok using the above html: 1234 abcd ...
7
by: 一首诗 | last post by:
Is there any simple way to solve this problem?
7
by: Sebarry | last post by:
Hi, I'm having trouble creating a blank table row in Javascript using document.createElement( '&nbsp;' ). When I look at the generated source it has intrepreted it as <td>&amp;nbsp;</td>. What do I...
9
hsriat
by: hsriat | last post by:
I have to toggle the name of a hyperlink from Edit to Save and vice-versa on click event of the same hyperlink. This is the HTML part, <input class="text" id="ix1" type=text></input> <a...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.