Question

I've been working on a site. Now that it's almost finished, w3c tells me that I misspelled the doctype. I had <!DOCTYPE html /> instead of <!DOCTYPE html>.

Now my layout changes as you can see in these pictures below.

How I created it:

How I created it

How it looks with the new instead of

What it looks like

What would be the most likely cause?

Was it helpful?

Solution

The <!doctype> element is used by browser to identify the correct interpretation of HTML. Your intention is to request an HTML5 interpretation, but if you mis-spell the <!doctype> the browser may misinterpret your request, or ignore the request altogether.

Depending on your browser the default operating mode might be some flavour of HTML4, or possible 'quirks mode' where known browser inconsistencies are maintained for the sake of backward compatibility.

Either of these operating modes carry some differences in interpretation from that applied to HTML5, so you see some formatting differences. I'm not going to be specific because you haven't posted the affected HTML, but you get the idea.

Note that an HTML5 doctype won't be recognised by earlier browsers, so you might have to be creative for browsers like IE6, or simply choose not to support them at all.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top