Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to know which <!DOCTYPE> type to use

i've searched and could not find any good explanation on here and on the internet many people outline what document types there are but don't explain how to determine which one would work best for your code....

so my question is how do i know which type of document type to declare in my webpage.....i know the difference between XHTML and HTML, i'm not asking that, i'm asking what type of document type such as:

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

OR

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

an explanation or links would help.....i appreciate it!

like image 502
nojohnny101 Avatar asked Aug 15 '13 07:08

nojohnny101


People also ask

Which HTML doctype should I use?

XHTML for validation The other thing is, if you put a premium on validating your code (as well as you can when coding for email), then we recommend the XHTML 1.0 transitional doctype. Naturally, not having a doctype will throw errors and the HTML5 doctype is still evolving.

Which doctype is correct for HTML5 <! doctype HTML5?

Explanation: The correct syntax of HTML5 doctype is <! doctype html>, doctype is the very first thing to write in HTML5.

How is HTML5 doctype different from normal HTML doctype?

Usage: In previous versions of HTML, the main usage of Doctype was to create a reference to DTD (Document Type Definition) and it was compulsory to refer to DTD but in HTML5, it doesn't need to refer to DTD.

What is the correct way to declare an HTML5 doctype?

To declare an HTML5 doctype, `<! DOCTYPE html>` is required in the first line of your HTML document. Doctype declaration for HTML5 is not case sensitive and does not require a closing tag.


2 Answers

You can use which you want, but in HTML 5 is recommend to use this:

<!DOCTYPE html>
like image 79
Prometheus Avatar answered Oct 14 '22 07:10

Prometheus


What works best for you depends on what your situation is.

If you want your HTML page to work correctly on very very old browsers that don't support <!DOCTYPE html> (and yes, there were such browsers, like Netscape 6) then the strict doctype is really the only possibility.

If you want your HTML page to validate, AND you must, for some reason that you don't want to reveal, use elements like <center> or <font> or <u>, then transitional is the doctype of choice.

However, those are really edge cases, and you should consider forgetting about them. In the majority of cases, <!DOCTYPE html> will do. Don't look to the past; look to the future.

like image 29
Mr Lister Avatar answered Oct 14 '22 08:10

Mr Lister