How to change the Document Mode in Internet Explorer to Standards value by using visual force page coding ? I need it to display the page correctly in IE.

  • Based on some the answers below, can you be more specific as to what the page needs? As Avidev notes, you can set the docType attribute to specify the actual HTML doctype. As jkraybill and Mohith point out - you can set a meta tag which will have some browsers (like IE) behave like a specific version.
    – joshbirk
    Mar 5 '13 at 13:43

There is a docType attribute in <apex:page> component you can set that to html-5.0

For Example

 <apex:page docType="html-5.0" />
  • 1
    I want to change the Document Mode to "Standards" Value in Internet explorer using coding which is not accomplished by above code if you have any work around please suggest me.
    – user1087
    Mar 2 '13 at 10:04
  • This does answer the question as it's phrased, but the solution is as per Jeremy's answer. It might be prudent to update the question to demonstrate why it renders incorrectly in IE.
    – Matt Lacey
    Mar 5 '13 at 1:08

I think you'll find the answer on this question helpful, it involves setting the X-UA-Compatible header via Apex. IE10 Forced into IE7 Standards document mode for Visualforce




One alternative is always adding the metatag

<title>The Page Title</title>
<meta http-equiv="X-UA-Compatible" content="IE=8" />
  • No Mohit above code doesn't change the document mode of IE to standards value.
    – user1087
    Mar 2 '13 at 13:07
  • Document Mode is overridden by the compatibility mode in IE.The compatibility mode along with doctype set determines the document mode.You may like to read the stackoverflow.com/questions/2950598/…. my answer explains how to change compactibility mode and Aridev one gives how to set doctype.Using combination of those you must reach to answer Mar 2 '13 at 14:33

To enable standards mode, you can include the html DOCTYPE declaration in a Visualforce page using an unescaped apex:outputText element at the beginning of the page, but it only works up until API version 26.0.

<apex:page contentType="text/html" docType="html" showHeader="false" sidebar="false" standardStylesheets="false">
<apex:outputText escape="false" value="<!DOCTYPE html>"/>
    <body onload="document.write((document.compatMode === 'CSS1Compat' ? 'Standards' : 'Quirks') + ' Mode');">

Set the apiVersion in your metadata:

<?xml version="1.0" encoding="UTF-8"?>
<ApexPage xmlns="http://soap.sforce.com/2006/04/metadata">
        <!-- Version CANNOT be greater than 26.0 to set doctype -->
        <label>Doctype Example</label>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.