Why we write <!doctype html> before <html> without this it is also working...give me the appropriate reason | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Why we write <!doctype html> before <html> without this it is also working...give me the appropriate reason

s

3rd Dec 2017, 9:29 AM
shamim raza
shamim raza - avatar
1 Answer
+ 6
Because it defines the document type (DocType) as HTML, browsers use that information to decide how the document contents should be rendered on screen. There were various document types defined previously, and <!DOCTYPE html> is the standard used by HTML5 and later. Further reading about document type definitions: https://www.w3.org/QA/2002/04/valid-dtd-list.html Hth, cmiiw
3rd Dec 2017, 9:42 AM
Ipang