+ 1
Is there any difference between declaring <!doctype html> or not in HTML code.
4 Antworten
0
yes there is a great difference in using both
we must use <!DOCTYPE HTML> if we're using HTML5 elements
if we're not using them, then we can use its usual way.
+ 4
Yes, there is an enormous difference between declaring a doctype or not, and between all the doctypes available:
Without it, browsers don't know wich version of Html was used to write the code, so no doctype provided means for browsers that's the much older version to be respected, and/or try kind of compatibility mode between whole versions... this will produce not expected display results :P
As @Naveen already said, for Html5 the doctype is just <!doctype html>: it was very simplified while previous version requiring a lot of unmemorzable specific urls to be included regarding each version flavour ^^
+ 4
@GAURAV wrote:
<< yes there is a great difference in using both
we must use <!DOCTYPE HTML> if we're using HTML5 elements
if we're not using them, then we can use its usual way. >>
You mark your own answer as best, but the "usual way" is to put a <!doctype> anyway...
<!doctype html> is for declaring an Html5 document, but you have other ( boring ) models for previous versions:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">
... and so on for every version/flavor :P
Without any <!doctype> declaration, you don't know how the user browser will consider your document... I wrote more about that here:
https://www.sololearn.com/Discuss/199097/is-it-still-relevant-to-put-doctype-html-at-the-beginning-of-an-html-file
0
For using HTML5 we write !doctypehtml.