W3C Validator - The document type does not allow the body element here

I am trying to verify the following code with a W3C validator :

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
    <title>Test</title>
</head>
<body>
</body>
</html>

I get two errors:

The document type does not allow the body element here

End tag for "html" that is not complete

Does anyone know how to fix this?

+3
source share
1 answer

You are using Frameset DTD , which does not allow the body. It is intended for use with framesets, which are used to display frames. Instead, you can use Strict:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
    <title>Test</title>
</head>
<body>
</body>
</html>
+8
source

Source: https://habr.com/ru/post/1758124/


All Articles