473,385 Members | 1,356 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,385 software developers and data experts.

CSS with <INPUT><LABEL></LABEL></INPUT>

TR
Is it possible with CSS to prevent this wrapping alignment with a checkbox
with a nested label?
[ ] This is the label of the
checkbox that wraps beneath it
I'd prefer it looked like this, with a flush left margin:
[ ] This is the label of the
checkbox that stays flush on its left margin

That is, the letter "T" of "This" is directly above the "c" of "checkbox",
rather than the INPUT [ ] being directly above the word "checkbox".

Can this flush left margin, with long labels that wrap, be achieved with
this markup? It seems it can't be done without unnesting the label from the
INPUT and wrapping INPUT and LABEL in separate DIVs.

<div class="chkitem">
<input id="box9221" type="checkbox" class="chkbox">
<label>
<a id="9221" href="http:/www...">This is the label ...</a>
</label>
</input>
</div>

Thanks for any help!
TR
Jul 21 '05 #1
3 13115
TR wrote:
Is it possible with CSS to prevent this wrapping alignment with a checkbox
with a nested label?
[ ] This is the label of the
checkbox that wraps beneath it
I'd prefer it looked like this, with a flush left margin:
[ ] This is the label of the
checkbox that stays flush on its left margin

That is, the letter "T" of "This" is directly above the "c" of "checkbox",
rather than the INPUT [ ] being directly above the word "checkbox".

Can this flush left margin, with long labels that wrap, be achieved with
this markup? It seems it can't be done without unnesting the label from the
INPUT and wrapping INPUT and LABEL in separate DIVs.

<div class="chkitem">
<input id="box9221" type="checkbox" class="chkbox">
<label>
<a id="9221" href="http:/www...">This is the label ...</a>
</label>
</input>
</div>


There's no such thing as </input>. Also, you left out the "for"
attribute of the LABEL tag, so there's no indication whatsoever what
field it's supposed to apply to.

You want something like:

div.chkitem { width: 30em; }
div.chkitem label { float: right; width: 28em; }
input.chkbox { width: 2em; }

....

<div class="chkitem">
<label for="box9221">
<a id="9221" href="http:/www...">This is the label ...</a>
</label>
<input id="box9221" type="checkbox" class="chkbox">
</div>

OR

div.chkitem { width: 30em; }
div.chkitem label { display: block; margin-left: 2em; }
input.chkbox { float: left; width: 2em; }

....

<div class="chkitem">
<input id="box9221" type="checkbox" class="chkbox">
<label for="box9221">
<a id="9221" href="http:/www...">This is the label ...</a>
</label>
</div>
Jul 21 '05 #2
Harlan Messinger wrote:
TR wrote:

[...]
Can this flush left margin, with long labels that wrap, be achieved with
this markup? It seems it can't be done without unnesting the label
from the
INPUT and wrapping INPUT and LABEL in separate DIVs.

<div class="chkitem">
<input id="box9221" type="checkbox" class="chkbox">
<label>
<a id="9221" href="http:/www...">This is the label ...</a>
That ID is invalid - names and IDs must start with a letter.

<URL:http://www.w3.org/TR/html4/types.html#type-name>
</label>
</input>
</div>

There's no such thing as </input>. Also, you left out the "for"
attribute of the LABEL tag, so there's no indication whatsoever what
field it's supposed to apply to.


In W3C conforming browsers, if a label has no 'for' attribute, it is
associated with its contents.

"for = idref [CS]
"This attribute explicitly associates the label being defined with
another control. When present, the value of this attribute must be
the same as the value of the id attribute of some other control in
the same document. When absent, the label being defined is
associated with the element's contents."

<URL:http://www.w3.org/TR/html4/interact/forms.html#adef-for>

However, IE does not conform in regard to the last statement.

[...]

--
Rob
Jul 21 '05 #3
RobG wrote:
Harlan Messinger wrote:

In W3C conforming browsers, if a label has no 'for' attribute, it is
associated with its contents.

"for = idref [CS]
"This attribute explicitly associates the label being defined with
another control. When present, the value of this attribute must be
the same as the value of the id attribute of some other control in
the same document. When absent, the label being defined is
associated with the element's contents."


Right, but in the OP's code the control isn't inside the LABEL element
either. Therefore, the label text isn't associated with the control,
rendering it functionally useless.
Jul 21 '05 #4

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

Similar topics

2
by: Xerxes | last post by:
Hi, can you tell me how I can make a <label> hidden? I have hidden the field after the label: var M_Hide = isNS4?'hide':'hidden'; var M_Show = isNS4?'show':'visible'; ..... <label...
5
by: Mikko Rantalainen | last post by:
See example at <URL:http://www.cc.jyu.fi/~mira/moz/formtest.php>. The problem is that the label of submit button is always centered on the button regardsless of 'text-align' property in CSS....
10
by: Brian Henry | last post by:
Hi, I am having a problem with an attachment system I made... it works with files up to ~3MB in size then after that if you try to upload a file it just goes to a "Page can not be displayed" page...
3
by: Josef K. | last post by:
Asp.net generates the following html when producing RadioButton lists: <td><input id="RadioButtonList_3" type="radio" name="MyRadioButtonList" value="644"...
1
by: five of nothing | last post by:
Hi, I'm working on a page and my HTML validator whines when I try to put a <div></div> or a <table></table> inside of an <a></a> tag. What are the rules as far as what can go in there?
2
by: Mara Guida | last post by:
Hi, After I've populated a page with some <INPUT ...> elements I'd like to have access to whatever is written there. The best I've done (which does not work) is: ================ //...
7
by: Smokey Grindle | last post by:
How can you correctly use the <labelelement in asp.net? does the label custom control corelate to this tag correctly in the same way in that if you click it it will select the tied element? thanks
2
by: Richard Maher | last post by:
Hi, I'm trying to use the Visibility Style attribute for a Div to effectively PopUp a lightweight window with some additional context-sensitive information, when a user mouses over a given...
3
Dormilich
by: Dormilich | last post by:
Hi, I just have one thing about the label element, where I’m not certain. <label> is commonly used to attach visual/text information to a form control. so far, so good. <!-- just to make it...
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: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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.