Getting W3C "document type does not allow element "LINK" here" even though links are in head?

StackOverflow https://stackoverflow.com/questions/20593911

Pregunta

I am running my site through the W3C validator and getting the error:

document type does not allow element "LINK" here"

for my external CSS style sheet links.

However, my links are within my head tags:

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

<head>

<title>Title</title>

<meta name="description" content="[[*description]]" />

<link rel="stylesheet" type="text/css" href="css/style.css" />

</head>

Would anyone know why this is occurring?

I am using the ModX Revo CMS if that matters.

¿Fue útil?

Solución

The link isn't in the head.

You are using HTML 4 so / will end a tag. This means that <meta /> is the same as <meta>> which is the same as <meta>&gt;.

You can't have character data in the <head> but the end tag for <head> and the start tag for <body> are optional. Therefore, <meta /> is the same as:

<meta>
</head>
<body>
&gt;

Since the link element appears after this, it is in the body.

Get rid of the /. You aren't writing XHTML.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top