HTML tags inside

前端 未结 3 1812
忘了有多久
忘了有多久 2020-12-15 15:05

I have a table in a page that consists of checkboxes in the cells on the left and descriptions in the cells on the right. The \"description\" contains h4 headers and plain t

相关标签:
3条回答
  • 2020-12-15 15:25

    Only inline elements (except other label elements) may appear inside label elements.

    <!ELEMENT LABEL - - (%inline;)* -(LABEL) -- form field label text -->
    

    — http://www.w3.org/TR/html4/interact/forms.html#h-17.9.1

    It doesn't make sense to put headings there anyway.

    0 讨论(0)
  • 2020-12-15 15:32

    The <label> element in HTML is an inline level element and cannot contain block level elements.

    This is probably what's causing your issues. Alternatively you can put your labels inside the <h4>'s :

    <tr><td><input type="checkbox" name="entiries[]" value="i1" id="i1"></td>
    <td><
    <h4><label for="i1">Some stuff</label></h4>more stuff..
    <h4><label for="i1">Some stuff</label></h4>more stuff..
    </label>
    </td></tr>
    
    0 讨论(0)
  • 2020-12-15 15:35

    Block level elements (to which h4 belongs) are not allowed inside inline elements, and will cause undefined behaviour. You can use span elements instead.

    0 讨论(0)
提交回复
热议问题