Contents

[edit]

OpenSP: Document type does not allow element %1 here

[edit]

Cause:

The element named above was found in a context where it is not allowed by the DOCTYPE Declaration.

This usually means that you have put a legitimate element someplace it shouldn't be -- such as a "style" element in the "body" section instead of inside "head".

One common cause for this error is the use of XHTML syntax in HTML documents. Due to HTML's rules of implicitly closed elements, this error can create cascading effects. For instance, using XHTML's "self-closing" tags for "meta" and "link" in the "head" section of a HTML document may cause the parser to infer the end of the "head" section and the beginning of the "body" section (where "link" and "meta" are not allowed; hence the reported error).

If you are using JavaScript to insert HTML into a document on the client-side, you need to hide the HTML elements in your JavaScript from the validator. This is especially true if you are working with XHTML.

[edit]

Examples

Improperly placed STYLE element:

Good
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
	<title>Stylin'</title>
</head>
<body>
	<style type="text/css">
	</style>
</body>
</html>
Good
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
	<title>Stylin'</title>
	<style type="text/css">
	</style>
</head>
<body>
</body>
</html>

XHTML syntax in an HTML document:

Good<link ... />
Good<link ... >

Un-escaped JavaScript in an XHTML document:

Good
<script type="text/javascript">
var output = "<html><body><p>Hi!<\/p><\/body><\/html>";
</script>
Good
<script type="text/javascript">
//<![CDATA[
var output = "<html><body><p>Hi!<\/p><\/body><\/html>";
//]]>
</script>
[edit]

Solution:

[edit]

References:

Retrieved from "http://www.htmlpedia.org/wiki/Sp_64"