How to Fix pages don't have doctype declared in WordPress

It is important to include it at the beginning of an HTML document to specify the version of HTML being used and to ensure that the document is displayed correctly in different web browsers.

If you encounter a page without a doctype declaration, it is considered bad practice and can cause compatibility issues with different browsers. To fix this, simply add the appropriate doctype declaration as the first line of the HTML document, before the <html> tag.

For example, to declare HTML5, you would use the following code:

<!DOCTYPE html>



    <title>Page Title</title>



    <h1>This is a Heading</h1>

    <p>This is a paragraph.</p>



Make sure to always include a doctype declaration in your HTML documents to ensure proper rendering and compatibility with different browsers.

How To Check the Issue

In order to ensure that your HTML document is valid, it is essential to have a DOCTYPE declaration as the first line. This declaration is a line of code that identifies the HTML version being used. To check if you have this line, you can access your HTML document and look for the declaration at the top of the code. Additionally, you can check it by right-clicking on the webpage and selecting “View Page Source.” If a DOCTYPE declaration is not present, it is necessary to add it in order for the HTML document to be valid.

To fix Doctype not Declared here are the steps.

Step 1:- Login To your WordPress account
Step 2:- Navigate to Appearance and then to Theme File Edit

image 8

Step3:- From Right-hand Files Select header.php

Step 4:- Paste the given code above <html


<!DOCTYPE html>

image 7

It’s important to note that the use of header.php is specific to websites built using the PHP scripting language, which is often used in conjunction with HTML. The header.php file typically contains the code for the header section of a website, which is included on every page of the site.

In this case, adding the doctype declaration as the first line of code in the header.php file is a good practice to ensure that it is included on every page of the website. However, it’s important to make sure that the doctype declaration is also included on every HTML page individually, as not all web pages will necessarily include the header.php file.

Regardless of whether you’re using PHP or not, the doctype declaration should always be the first line of code in your HTML document, before any other HTML tags. This ensures that the web browser knows which version of HTML to use and renders the page correctly.

WordPress is a content management system that is designed to automatically generate a valid doctype declaration in the HTML output. Therefore, it’s unlikely that a WordPress site would be missing a doctype declaration unless it was intentionally removed or modified by the website developer.

If you do happen to notice that the doctype declaration is missing from your WordPress site, it’s important to add it back in to ensure that your website is displayed correctly in different web browsers. To do this, simply insert the appropriate doctype declaration as the first line of code in your theme’s header.php file or in your individual page templates.

Also check:- How to Fix pages don’t have doctype declared in Shopify

Once you’ve added the doctype declaration, save the file and refresh your web page to see if the issue has been resolved. If the problem persists, you may need to consult with a web developer or WordPress expert to troubleshoot the issue further.


What happens when you remove doctype from the HTML page

The DOCTYPE tag is a required part of all HTML documents. In HTML5, the tag used is . Without a DOCTYPE, the browser will enter Quirks Mode and try to deal with the code as if it was written in the late 1990s. This means that the browser will imitate many of the bugs that existed in the old browsers and will not render the elements correctly. Furthermore, the lack of a DOCTYPE may result in inconsistent results across browsers.

What happens if I don’t put a in my code?

If you do not include a in your code, browsers may not render your web page correctly or may not render it at all. This is because the browser may not be able to determine which version of HTML you are using and thus, may not be able to interpret the code correctly.

What happens when there is no doctype in a web page

When there is no doctype in a web page, the browser will enter quirks mode. Quirks mode is a compatibility mode that browsers use to render pages that were created for older browsers. It is important to note that quirks mode is not a standard, and different browsers may render pages in quirks mode differently

If you don’t put doctype html will html5 work

HTML5 will still work if you don’t put a doctype declaration in your HTML document. However, it is best practice to always include a doctype declaration, as this will tell the browser to render the page in standards mode. Standards mode is the most reliable and predictable mode, and it will help to ensure that your page is rendered consistently across different browsers.

Leave a Reply

Your email address will not be published. Required fields are marked *