Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it valid to use a <div> inside a <label>? [duplicate]

Tags:

html

css

I've a label element whose contents needs some styling. This label can't be adjusted, so it would be handy to use a <div> or block-level elements inside the label. So I'm wondering if it is valid to use a <div> in a <label> in HTML5.

like image 985
Amber Avatar asked Mar 11 '16 13:03

Amber


1 Answers

the label element:

Content model:
Phrasing content, but with no descendant labelable elements unless it is the element's labeled control, and no descendant label elements.

phrasing content:

a abbr area (if it is a descendant of a map element) audio b bdi bdo br button canvas cite code data datalist del dfn em embed i iframe img input ins kbd keygen label map mark math meter noscript object output progress q ruby s samp script select small span strong sub sup svg template textarea time u var video wbr text


So no. Div elements may not be descendants of labels.

like image 86
Quentin Avatar answered Nov 15 '22 07:11

Quentin