<label><div></div></label> allowed?

J

Josef K.

Asp.net generates the following html when producing RadioButton lists:


<td><input
id="RadioButtonList_3"
type="radio"
name="MyRadioButtonList"
value="644"
onclick="__doPostBack('SitesRadioButtonList_3','')"
language="javascript" />

<label for="SitesRadioButtonList_3">Central Division<span
class='sitedescription'>plains states including Texas</span></label>

</td>

My question is, is it well-formed HTML to nest a <div></div> inside the
<label></label> tag? Could I replace the <span>...</span> with a
<div>...</div> ?

Thanks
K.
 
B

Bruce Barker

yes, the main difference is a div is a block element and a span is a inline
(unless you override the style).

-- bruce (sqlwork.com)
 
A

Adrienne

Asp.net generates the following html when producing RadioButton lists:


<td><input
id="RadioButtonList_3"
type="radio"
name="MyRadioButtonList"
value="644"
onclick="__doPostBack('SitesRadioButtonList_3','')"
language="javascript" />

There is no attribute language for the INPUT element. The language
attribute is valid only for the SCRIPT element. Further, the language
attribute is deprecated and should only read: <script
type="text/javascript"...>

If you are on the WWW, you also have to worry about users with javascript
disabled and make sure the form will post without it.
<label for="SitesRadioButtonList_3">Central Division<span
class='sitedescription'>plains states including Texas</span></label>

</td>

My question is, is it well-formed HTML to nest a <div></div> inside the
<label></label> tag?

You cannot nest a block level element inside of an inline element. Label
is an inline element, DIV is block level.
Could I replace the <span>...</span> with a
<div>...</div> ?

No. Again, you cannot nest block level elements in inline elements. Span
is an inline element, so it CAN be nested inside another inline element,
like Label.

http://www.w3.org/TR/html4/index/elements.html
http://www.w3.org/TR/html4/index/attributes.html
 
J

Josef K.

Thanks for the explanation and links (and the advisory about the standards
issues).
K
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,997
Messages
2,570,241
Members
46,831
Latest member
RusselWill

Latest Threads

Top