Does doctype is really necessary at top of the html? | Sololearn: Learn to code for FREE!
¡Nuevo curso! ¡Todo programador debería aprender IA Generativa!
Prueba una lección gratuita
+ 2

Does doctype is really necessary at top of the html?

I've found that html works without having <!doctype html> at top of our document. Then what is the use of having it in our document.?

2nd Dec 2017, 2:55 AM
VARUN KUMAR PADALA
VARUN KUMAR PADALA - avatar
4 Respuestas
+ 8
of course it works, but the DOCTYPE action is to tell the browser what version of HTML it is running in order to validate our document, so it is always recommended to include it look this: https://www.w3.org/wiki/Choosing_the_right_doctype_for_your_HTML_documents
2nd Dec 2017, 3:09 AM
Félix Icaza
Félix Icaza - avatar
+ 3
You can drop <body> or <html> too and the site will look fine. It's invalid HTML, but browsers will play nice and fill in the gaps. Always include it, it's just one line :P
2nd Dec 2017, 3:13 AM
Schindlabua
Schindlabua - avatar
+ 2
You can just put plain text, html still works.
2nd Dec 2017, 4:36 AM
Calviղ
Calviղ - avatar
+ 1
It depends whether you are using HTML4 or HTML5 HTML5 requires <! doctype html> tag at the top
2nd Dec 2017, 5:24 AM
#RahulVerma
#RahulVerma - avatar