Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it safe to simply change web page doctype HTML 4.01 or XHTML 1.0 to doctype HTML5?

Tags:

html

doctype

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.

like image 278
Morgan Cheng Avatar asked Jan 23 '12 15:01

Morgan Cheng


People also ask

What DOCTYPE should I use for HTML5?

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.

Are there change to DOCTYPE for HTML5?

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.

Will HTML5 work without DOCTYPE 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,...)

Does HTML5 allow the use of XHTML?

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.


1 Answers

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.

like image 52
Madara's Ghost Avatar answered Sep 28 '22 11:09

Madara's Ghost