Search code examples
htmldoctypestricttransitional

Questions about Doctype


I started working on a project and forgot to mention the DOCTYPE at the beginning and just used <html>. I feel really stupid about doing it, right now. The webpage heavily realizes on javascript and I have a lot of instances of the document height and scrollTop. Now I just realized that and added a Doctype. This messed up the whole page. I tried transitional and strict, but all the doctypes have the same effect. My question is if the default doctype is always<!DOCTYPE html>? I read online that if no doctype is specified it always resorts to <!DOCTYPE html>. I tried changing it to that, but it still messes up the website. So could


Solution

  • This is probably because you are using elements that are associated with a specific DOCTYPE. <!DOCTYPE html> defaults to html5. If no DOCTYPE is specified, you webpage defaults to quirks mode. Since you set everything up according to this standard, it isn't compatible with a standard mode.