问题
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