Is it semantically incorrect to put a <div> or <span> inside of a <button>?
I'd like to do the following, but is it semantically correct?
<button>
<div></div>
<div></div>
</button>
The current HTML5 draft says it is incorrect.
http://www.w3.org/TR/2012/WD-html5-20120329/the-button-element.html#the-button-element says that a <button>
must contain only Phrasing content. Phrasing content is defined as including <span>
but not <div>
.
No it is not valid. You can verify it at W3C.
http://validator.w3.org/#validate_by_input+with_options
Paste this in the direct input and then validate.
<!DOCTYPE html>
<button>
<div></div>
<div></div>
</button>
Set the UTF8 encoding and select HTML5 when testing at W3C.