What does a doctype do in an HTML document?

suparman21 asked this question 8 months ago
suparman21 on Jan 27 · Edited

What does the doctype do in HTML code?

For example, this line of code is in a lot of HTML code I see:

<!DOCTYPE html>

What is the purpose of that?

1 suggested answers
rusty1_rusty1 on Feb 6

It tells the browser what version of HTML the page is written in. This ensures your HTML is parsed the same way by each different browser.

Read more information here: https://html.spec.whatwg.org/multipage/syntax.html#the-doctype.

0 replies