How to Fix “Pages Don’t Have Doctype Declared” from Semrush Audit


Table of Contents

When web pages lack a doctype declaration, it means they don’t specify the type of document being used, which can lead to various rendering and compatibility issues across different browsers. This issue often arises when HTML documents are not properly structured, potentially affecting their appearance and functionality.

How to Fix "Pages Don't Have Doctype Declared" Detected by a Semrush Audit

Why is it important for you to fix this issue? Fixing the “Pages Don’t Have Doctype Declared” error is crucial for ensuring consistent and reliable performance of your website across different platforms and devices. By declaring the correct doctype, you provide clear instructions to browsers on how to interpret and display your web pages, resulting in a better user experience and improved search engine optimization.

How to Fix “Pages Don’t Have Doctype Declared” Detected by a Semrush Audit

How to Fix "Pages Don't Have Doctype Declared" Detected by a Semrush Audit

1. Identify the affected pages

Start by identifying which pages on your website are experiencing this issue. You can use the Semrush audit report or other website auditing tools to pinpoint the pages lacking a doctype declaration.

2. Access the HTML code

Once you’ve identified the problematic pages, access the HTML code for each of them. You can do this by logging into your website’s content management system (CMS) or by using an HTML editor.

3. Locate the opening <html> tag

Within the HTML code of each page, locate the opening <html> tag. This is typically found at the beginning of the document, near the top of the code.

4. Insert the doctype declaration

Directly above the opening <html> tag, insert the appropriate doctype declaration for the version of HTML being used. For example:

  • For HTML5: <!DOCTYPE html>
  • For HTML 4.01: <!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01//EN” “”>
  • For XHTML: <!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “”>

5. Save and update the page

After adding the doctype declaration, save the changes to the HTML code and update the affected page on your website. Make sure to repeat this process for each page identified with the error.

6. Validate the changes

Once you’ve updated the pages, it’s essential to validate the changes to ensure the doctype declaration is correctly implemented. You can use online HTML validation tools such as the W3C Markup Validation Service to check for any remaining issues.

7. Re-audit with Semrush

After fixing the “Pages Don’t Have Doctype Declared” error, re-run the audit with Semrush or your preferred website auditing tool to confirm that the issue has been resolved. This step ensures that your website maintains optimal performance and compliance with web standards.

By adhering to these steps, you can proficiently rectify the “Pages Don’t Have Doctype Declared” issue highlighted by a Semrush audit, consequently enhancing your website’s quality and accessibility. However, if despite these efforts the problem persists, seeking guidance from our SEO specialist could offer valuable insights and assistance in resolving the issue effectively.

Share a post

Request a
free website audit

What to read next