In short
Semrush flags "Doctype not declared" when a page doesn't start with a doctype. Browsers then use "quirks mode," which mimics very old browser behavior and can change how layouts and sizes render. Add <!DOCTYPE html> as the first line of the page template.
The doctype is the very first line of an HTML page. Without it, browsers fall back to old rendering rules.
The fix
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
Nothing, not even a blank line or a comment, should come before it ideally.
Where it goes missing
Old themes or hand-coded templates.
PHP warnings or stray output printed before the template starts.
Pages built by hand outside the CMS (landing pages, old static files).
WordPress: check header.php in your theme, and look for plugins printing output early. Shopify: check theme.liquid. Webflow and Wix: added automatically; flags usually point to custom-coded files. Custom builds: add it to the base layout.
This guide isn't affiliated with or endorsed by Semrush.
Related issues
Sources and references
Semrush Knowledge Base, What Issues Can Site Audit Identify?
MDN, Quirks mode

About the author
Nazmul Nikhil
Head of SEO & Assistant Manager, Digital Marketing at Notionhive
SEO and AI search consultant in Dhaka, Bangladesh, helping small and mid-size businesses in the USA, UK, Australia and Canada.



