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

Discussion in 'ASP .Net' started by Josef K., May 20, 2005.

  1. Josef K.

    Josef K. Guest

    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.
     
    Josef K., May 20, 2005
    #1
    1. Advertising

  2. Josef K.

    Bruce Barker Guest

    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)


    "Josef K." <> wrote in message
    news:%2323mw%...
    > 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.
    >
    >
     
    Bruce Barker, May 21, 2005
    #2
    1. Advertising

  3. Josef K.

    Adrienne Guest

    Gazing into my crystal ball I observed "Josef K." <>
    writing in news:#23mw#:

    > 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

    --
    Adrienne Boswell
    http://www.cavalcade-of-coding.info
    Please respond to the group so others can share
     
    Adrienne, May 21, 2005
    #3
  4. Josef K.

    Josef K. Guest

    Thanks for the explanation and links (and the advisory about the standards
    issues).
    K
     
    Josef K., May 22, 2005
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    1
    Views:
    3,403
    Michael Mayer [C# MVP]
    Feb 16, 2004
  2. Wiseguy
    Replies:
    2
    Views:
    332
  3. K Viltersten

    <div ... /> and <div ...></div>

    K Viltersten, Mar 30, 2009, in forum: ASP .Net
    Replies:
    4
    Views:
    756
  4. Iñaki Baz Castillo
    Replies:
    13
    Views:
    505
    Iñaki Baz Castillo
    May 1, 2011
  5. Knut Krueger
    Replies:
    8
    Views:
    280
    Knut Krueger
    Aug 20, 2013
Loading...

Share This Page