Cedric Cedric - 4 months ago 20
HTML Question

What are the differences that a doctype make in a html page?

What is the difference between having a page doctype or not having one, apart from the fact that the page should have one ?

I am asking that because I use a slider inside this page - with the doctype, the slider has a wrong high (150px), and without it, it has the desired high (with the correct ratio high/width from the iframes which are in the slider).

I have tried with multiple doctypes, with the same result for each of them.

Answer

Without a doctype to state what flavour of html you are using, the browser will revert to quirks mode, where it tries to parse your markup through a series of best guesses. Nothing about this is optimal. You have an invalid hypertext document and the browser can only guess at how to parse it.

In short, you need a doctype at the start of every hypertext document.


For a Complete List of HTML and xHTML Doctype Declarations, see:

https://www.w3.org/QA/2002/04/valid-dtd-list.html