Forum Moderators: open
we have this doctype declaration on our site:
<!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" xml:lang="en" lang="en">
now with this declaration, shouldnt there be a content type declaration or a xml declaration..? i.e.
Content-Type: text/html; charset=utf-8
or
<?xml version="1.0" encoding="utf-8" ?>
im confused as to which one we should be using?
You should, however, always declare the document charset, either via a HTTP header or with a meta charset element placed before the
title element.
<?xml version="1.0" encoding="utf-8"?>
<!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" xml:lang="en" lang="en">
<head>
<title>An XHTML 1.0 Strict standard template</title>
<meta http-equiv="content-type"
content="text/html;charset=utf-8" />
<meta http-equiv="Content-Style-Type" content="text/css" />
</head>
<body>
<p>… Your HTML content here …</p>
</body>
</html>
This would be better as a basic XHTML 1.0 Transitional template:
<!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" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>XHTML 1.0 Transitional template</title>
</head>
<body>
<p>… Your HTML content here …</p>
</body>
</html>
As for the following line:
<meta http-equiv="Content-Style-Type" content="text/css" /> It should be present in theory, in practice it is not required. This is because the default, and indeed only existing style type currently supported in browsers is
text/css. For the meta charset element, the recommendation is that it be placed as high as possible in the head section, before any content (including the title element). In practice, placing it after the title (as in the W3C template) is not a problem.