Self-closing tags (void elements) in HTML5

前端 未结 5 416
不知归路
不知归路 2020-11-28 12:10

Step 6 of 8.1.2.1 Start tags of the HTML5 spec says that void elements may have a single / character. I think this is so it\'s easier to migrate sites

5条回答
  •  独厮守ぢ
    2020-11-28 12:13

    Mostly it depends if you want to go the XML route or not. Both should render correctly, as the HTML5 spec does not require self-closing tags - their only reason is that the document is then valid XML.

    The easier way is to probably just write then without the self-closing "/", unless there's a specific need to get the markup parsed as XML - in that case you also need

    
    

提交回复
热议问题