Is it semantically incorrect to put a
or inside of a <button>?

后端 未结 5 1149

I\'d like to do the following, but is it semantically correct?


         


        
5条回答
  •  攒了一身酷
    2020-11-30 14:05

    Div and span elements do not have any semantics. They are generic block and inline elements. The only question you need to ask yourself about semantics when you are using them is Is there an element with better semantics for this content?.

    That said, it is incorrect to place a div inside a button for reasons unrelated to semantics. The specification says about the content model for buttons:

    Phrasing content, but there must be no interactive content descendant.

    … a span is phrasing content but a div is not.

提交回复
热议问题