Note: This release is in preview. Features described here don’t become generally available until the latest general availability date that Salesforce announces for this release. Before then, and where features are noted as beta, pilot, or developer preview, we can’t guarantee general availability within any particular time frame or at all. Make your purchase decisions only on the basis of generally available products and features.
Using a Custom Doctype
By default, Visualforce pages are served with a doctype of HTML 4.01 Transitional. Specifically, pages begin with this doctype declaration:
1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">You can specify a different doctype for a Visualforce page by using the docType attribute on the <apex:page> tag.
The docType attribute takes a string representing the document type. The format of the string is:
1<doctype>-<version>[-<variant>]where
- doctype is either html or xhtml
- version is a decimal version number valid for the doctype
-
variant, if included, is:
- strict, transitional, or frameset for all html document types and the xhmtl-1.0 document type, or
- <blank> or basic for the xhmtl-1.1 document type
If an invalid document type is specified, the default doctype is used. For more information about valid HTML doctypes, see the list at the W3C website.
Custom Doctype Example
To create a Visualforce page with an XHTML 1.0 Strict document type, use the docType attribute on the <apex:page> tag, and specify a value of xhtml-1.0-strict:
1<apex:page docType="xhtml-1.0-strict" title="Strictly XHTML"
2 showHeader="false" sidebar="false">
3 <h1>This is Strict XHTML!</h1>
4 <p>
5 Remember to close your tags correctly:<br/>
6 <apex:image url="/img/icon-person.gif" alt="Person icon"/>
7 </p>
8</apex:page>