I have left doctype out for everything except IE on a homepage is that OK?

Posted on 2012-08-12
Last Modified: 2012-08-24
I have several javascript scripts running on a page and it seems that if I removed the doctype  for all browsers except IE, it all works fine. Otherwise I get a conflict.
From what I have read having no doc type should render them into "quirk mode".
Is this OK? It's just for this main page of the site , all else has a doctype.

Thanks in advance.
Question by:colonelblue
    LVL 17

    Expert Comment

    <!doctype html>

    Open in new window

    If its html it should
    SHould work fine.....

    Brief Desc.
    LVL 82

    Assisted Solution

    by:Dave Baldwin
    I never heard of a way to only provide a DOCTYPE to only one browser.  I also never heard of a DOCTYPE having a direct effect on javascript.  Show us a link to the page.
    LVL 6

    Assisted Solution

    Triggering quirks mode shouldn't be an aim for your coding. You may not get errors being displayed, but you'll probably get elements just not working at all.

    Setting up your page correctly should be the first step. I suggest HTML 5 boilerplate.

    Second, run the page and discern the errors created from the scripts you are running.
    IE and Chrome - hit F12.
    FF - add Firebug add-on and hit F12.

    As IE seems to be happy with the broken code, I strongly suggest you use one of the other browsers for determining the error. More than likely, the scripts you've added are using old IE only syntax.

    You can also display the scripts and HTML here for debugging.
    LVL 53

    Assisted Solution

    FF and Chrome do not use quirksmode.  That is an IE thing to try and get compatibility with the ancient crude in older version.  The good browsers default to "almost standards mode".


    If you need to remove doctype for the page to work then the page is seriously defective and needs to be fixed.  Removing the doctype is definitely not a valid approach.

    LVL 82

    Assisted Solution

    by:Dave Baldwin
    LVL 53

    Accepted Solution

    Hmmm...... interesting and even more so in that the Mozilla page actually has a link to the page I posted the link for.

    I don't really worry much about mode, because I always use a modern doctype, but I probably should not be surprised that Mozilla can do quirksmode, as it is the most flexible and best browser around. :^)


    Author Closing Comment

    I'm sorry I had not responded sooner. Thank you for pointing me the right way to look for a solution.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Should I Do With This Threat Intelligence?

    Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

    Suggested Solutions

    Why do we like using grid based layouts in website design? Let's look at the live examples of websites and compare them to grid based WordPress themes.
    I've been asked to discuss some of the UX activities that I'm using with my team. Here I will share some details about how we approach UX projects.
    The viewer will learn how to dynamically set the form action using jQuery.
    The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

    794 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now