How to change doctype declarations in Magento 1.x

If you ever experience following w3c ( html validating errors? Solution is checking your Magento 1.x template files and set valid document type specified by W3C.

W3C DOCTYPE validating errors

  1.  “DOCTYPE” declaration not allowed in instance
  2. no document type declaration; will parse without validation
  3. document type does not allow element “HTML” here

Here is correct W3C reference for valid doctype.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "">
<html xmlns="" lang="en" xml:lang="en">
<!-- ... body of document ... -->


  1. Open your template files located in magento installation directory located at /app/design/frontend/YOUR-TEMPLATE-FOLDER/template/page
  2. Open following files in your favourite editor.
  3. Check the following code before starting <head> section. You shouldn’t place any php codes or any other script tags before starting <!DOCTYPE tags. In Magento there should be only DISCLAIMER notice top of the <!DOCTYPE.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "">
<html xmlns="" xml:lang="<?php echo $this->getLang() ?>" lang="<?php echo $this->getLang() ?>">

Magento replace “xml:lang” and “lang=” section with php echo statements. It’s normal behaviour in Magento and you don’t need to change this.
Hope this article help you to avoid W3C validation errors for Magento stores.
Please check W3C valid DTD list at