Is it safe to simply change the HTML version of an HTML 4.01 or XHTML 1.0 HTML page to doctype HTML5?

Suppose I want to change an outdated website as "HTML5". Is it possible to simply change the doctype header as shown below?

 <!doctype html> 

The original doctype may 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> cannot ruin the way the old web page is displayed, I would suggest that it is safe.

+8
html5 doctype
source share
5 answers

Why yes, yes, it is.

In fact, HTML5 was specifically designed for this, so anyone could just change their doctype without touching the markup, and that would be true.

+5
source share

Almost safe.

This doctype:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

calls restriction mode with restrictions / almost standards in browsers, while this doctype:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

and this doctype

<!doctype html>

call standards mode in browsers.

The difference is that some inline elements are vertically aligned in rows.

+5
source share

If your “free” document contains outdated tags, such as “font” or “frameset”, the page will not be checked after changing it in HTML5. Will this work? Yes, probably. Will it really be? Depends on the actual content. Most likely, your strict documents, if they are valid, will be valid, but "free" may not be so.

What will happen to the display? It depends. I found that changing the transition document to HTML5 leads to display changes in some browsers - in some cases, radical enough that I had to cancel them before I could rewrite the pages in question.

+2
source share

It depends on your definition of security.

It will reliably run the same rendering modes in browsers, so you won’t get any differences that will affect end users.

It will also change the rules that the validator will use to validate the document, so it can create problems for your QA process because the documents need to be updated.

+1
source share

I just found out that it is NOT safe. I need some HTML5 elements on an old website that has been running for several years. I needed to change doctype to html, because some browsers will not work with new elements otherwise.

It turned out that in javascript domobject.name does not work with the new doctype . You must use domobject.attributes["name"].value . In short, this simple thing has created serious problems with the functionality of the website.

Thus, it is best to check everything after changing the doctype , because it can break down various things that you would not think about ...

+1
source share

All Articles