DEV Community

Karen Molina
Karen Molina

Posted on • Updated on

The coding interview: !DOCTYPE

Hi, once again!

Two years ago, I took my first job as frontend developer. Before that, I did workshops about STEAM for kids. And before at that I was studied Social Anthopology. So, a few months ago I applied to one of the big unicorns in LATAM, but I can't passed the proccess. My weakness: the theory.

For that reason, I have been studying and reviewing about programming fundamentals. And thats why I have been decided create a serie of posts about technical interviews. To help other new and future programmers to get their dream jobs. Or to help them to give their best in a future interview.

First we started with some of HTML. Why?, because, as a web developers the HTML is one of our three most important tools to create our projects.

What is the !DOCTYPE?

In every html file we must put !DOCTYPE in the first line, but, why?. First the !Doctype is not a html tag, but it's a keyword. This keyword works as a declaration to the browser. I mean, with that we says to the browser what document type must to expect. In that case, an HTML 5 file.

The complete declaration must be like:

<!DOCTYPE html>.

Before HTML5, the declaration was more confused, because we had used some thing called Document Type Definition. But, don't worry, now, we dont have to use that. But other thing we have to know and help us in the future is about the case sensitive. The !DOCTYPE is not case sensitive. So, we can write with capitalize, uppercase, lowercase, camelcase ways. Not matters!.

Discussion (3)

Collapse
alohci profile image
Nicholas Stimpson • Edited

DOCTYPE can't be removed from the standard unless all the old web pages that rely on it not being there are erased from the WWW. In many ways, the opposite is true. The way that browsers behave when faced with a HTML document that doesn't start with a DOCTYPE has been standardized. That's why the HTML5 spec doesn't refer to "quirks-mode", "almost standards mode" and "standards mode", but to "quirks mode", "limited-quirks mode" and "no-quirks mode", i.e. because all three are "standard".

It follows from that, that <!DOCTYPE html> at the start does not indicate a HTML5 document. In fact, a document that contains no DOCTYPE is also an (albeit invalid) HTML5 document, just one that will be rendered using quirks mode.