Should I remove trailing slashes in meta tags?

这一生的挚爱 提交于 2019-12-23 07:27:59

问题


W3c markup validation is asking me to remove trailing slashes on my page. Is this correct? Aand will my page still be compliant in all browsers?

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">

<meta http-equiv="content-style-type" content="text/css" **/**>

回答1:


That is correct. For HTML 4.01 you shouldn't have trailing slashes (self-closing tags) for meta elements and I believe <link> elements if memory serves me correctly.

xhtml requires trailing slashes, though.




回答2:


XHTML is HTML with an XML syntax. In XML all tags must be closed. Some HTML tags do not have closing tags so in XHTML they need to be self closed. This is achieved through placing an / in front of the >.

So any tags that you have with /> must be changed to remove the forward slash to be HTML conformant.

These aren't the only differences between the two specifications.



来源:https://stackoverflow.com/questions/3310921/should-i-remove-trailing-slashes-in-meta-tags

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!