V
V
viktorross2019-09-11 00:01:38
HTML
viktorross, 2019-09-11 00:01:38

Why can't a div be a child of a label?

Please tell me what is wrong here?

<div class="lfloat half" style="line-height: 40px;">
<label for="remember" class="options_left enh_checkbox chk_container">
<input type="checkbox" name="remember" id="remember" class="inline noborder" tabindex="3"/>
<span>{$lng.remember_me_rormatted}</span>
<div class="chk_indicator"></div>
</label>
</div>

Error: Element div not allowed as child of element label in this context. (Suppressing further errors from this subtree.)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Rsa97, 2019-09-11
@viktorross

Because according to the standard label has a Phrasing content model, and can only contain a certain set of tags (excluding nested label)

L
lexchz, 2019-09-11
@lexchz

label is an inline element and div is a block element. Generally, block-level elements inside inline elements are not allowed. Although there are some points, for example, the validator does not swear on the div inside the link.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question