Helen Grimbly, Support Lead
This week, Support Lead, Helen Grimbly is looking at the document type declaration, or DOCTYPE.
The <!DOCTYPE> declaration is an instruction to the web browser about what version of HTML the page is written in.
It is important for webpages to comply with current HTML standards, because the webpages are then more likely to be supported across different browser types (e.g. Internet Explorer, Google Chrome, Mozilla Firefox, Safari) and therefore more likely to work as expected.
The <!DOCTYPE> declaration must be the first thing in your HTML document, before the <html> tag.
You cannot use HTML 5 features if your document has an HTML 4 or XHTML 1 doctype. Also you cannot just put an HTML 5 doctype on a non HTML 5 document as it is not fully backwards compatible with earlier versions of HTML.
HTML 5 doctype:
HTML 4.01 Strict:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
XHTML 1.0 Transitional:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
In order for Sitemorse Code Quality category diagnostics of type file/html/ to pass, the page has to comply with the rules for the HTML doctype specified. For example for HTML 5 pages this relates to the rules laid out in the W3C HTML 5 specification, which is currently https://www.w3.org/TR/html51/ .