What is !DOCTYPE?
Experience Level: Junior
Tags: HTML
Answer
- The
<!DOCTYPE>
is a declaration that defines at what version of HTML the page is written in. In helps the browser to understand how it should read the document. - If the
<!DOCTYPE>
is ommitted, the browser is trying to interpret the document, but it could be displaying it incorrectly. For that reason always add the<!DOCTYPE>
to you document. - The
<!DOCTYPE>
declaration must be the first thing in your HTML document. It has to be even before the<html>
tag. - The
<!DOCTYPE>
declaration is not a tag.
<!DOCTYPE html>
<html>
<head>...</head>
<body>
...
</body>
</html>
Other !DOCTYPEs
<!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">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML Basic 1.1//EN"
"http://www.w3.org/TR/xhtml-basic/xhtml-basic11.dtd">
Related HTML job interview questions
What is <sup> tag?
HTML JuniorWhat is <sub> tag?
HTML JuniorWhich version of HML do you use?
HTML JuniorWhat is <figure> tag?
HTML JuniorHow does HTML/CSS work with DOM?
HTML Junior