Suppose I want to change a legacy web site to be "HTML5"-ish. Is it safe to simply change the heading doctype
as below?
<!doctype html>
The original doctype might be:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
or
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
If changing to <!doctype html>
has no possibility of ruining how the legacy web page is rendered, I would assume it is safe.
In the modern age of HTML5, web standards are fully implemented in all major browsers. Web sites are generally developed in a standards compliant way. Because of this the HTML5 doctype declaration only exists to tell the browser to render the document in full standards mode.
You can change it. Almost all browsers just look for html in the doctype to ensure they are parsing HTML. It will also remain the same with new versions of HTML.
DOCTYPE html> // Tells the browser that we are using HTML5. If document type is not mentioned, browser will go to Quirks mode. Quirks mode depends upon the web browser version, If is older version then this will not support HTML5 tags (Example: header tag, footer tag, section tag,...)
You can write HTML5 with XHTML 1.0 syntax, since HTML5 permits XML syntax and it explicitly allows an XHTML 1.0 doctype as “legacy doctype” in the XHTML syntax.
Why yes, yes it is.
As a matter of fact, HTML5 was designed specifically for this, so that anyone could simply change their doctype without touching the markup and it would be valid.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With