DOCTYPE Switches support in Opera Presto 2.10

Web references
WML 2.0 Specification (PDF)
Microsoft's DOCTYPE Switch Documentation
Mozilla's DOCTYPE Switch Documentation
A DOCTYPE Switch Browser Comparison

Overview

While Opera Presto is well capable of showing standards-compliant pages correctly, not all Web pages are compliant. To be able to both display all standards-compliant pages and the other pages as well, three different display modes are present in Opera:

Which of the modes is selected depends on which Document Type Declaration (DOCTYPE) the page is using.

Internet Explorer (from 6.0 on for Windows and 5.0 on for Mac) and Mozilla/Netscape (from versions 0.6 and 6.0 respectively) also use DOCTYPE switches. Opera Presto uses similar rules as IE6 for Windows to determine whether to enter Standards Mode or Quirks Mode.

Document types

The following table represents DOCTYPEs triggering standards compliant behavior in Opera 7 and later, IE6 for Windows, and Netscape 7.

Document type Example Document Type Declaration URL present URL absent

1 When XHTML is delivered as text/html and includes the XML declaration, Quirks mode is triggered for IE and Opera 7.0-7.03. From Opera 7.1 onwards, the XML declaration, PIs, and comments are ignored for determining display mode. When delivered as XML, Opera uses Standards mode.

2 Only Opera recognizes the WML doctypes

No DOCTYPE Quirks Quirks
HTML 2.0 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> Quirks Quirks
HTML 3.0 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 3.0//EN//"> Quirks Quirks
HTML 3.2 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> Quirks Quirks
HTML 4.0 Frameset <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Frameset//EN" "www.w3.org/TR/REC-html40/frameset.dtd"> Quirks Quirks
HTML 4.0 Transitional <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "www.w3.org/TR/REC-html40/loose.dtd"> Quirks Quirks
HTML 4.0 Strict <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "www.w3.org/TR/REC-html40/strict.dtd"> Standards Standards
HTML 4.01 Transitional Frameset <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "www.w3.org/TR/html4/frameset.dtd"> Almost Standards Quirks
HTML 4.01 Transitional <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "www.w3.org/TR/html4/loose.dtd"> Almost Standards Quirks
HTML 4.01 Strict <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "www.w3.org/TR/html4/strict.dtd"> Standards Standards
HTML5 <!DOCTYPE html> Standards Standards
XHTML 1.0 Strict <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML Strict 1.0//EN" "www.w3.org/TR/xhtml/DTD/xhtml1-strict.dtd"> Standards 1 Standards 1
XHTML 1.0 Transitional <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML Transitional 1.0//EN" "www.w3.org/TR/xhtml/DTD/xhtml1-transltional.dtd"> Almost Standards 1 Almost Standards 1
XHTML 1.0 Frameset <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML Strict 1.0//EN" "www.w3.org/TR/xhtml/DTD/xhtml1-frameset.dtd"> Almost Standards 1 Almost Standards 1
WML 2.0 <!DOCTYPE html PUBLIC "-//WAPFORUM//DTD WML 2.0//EN" "www.wapforum.org/DTD/wml20.dtd"> Standards 2 Standards 2
Unrecognized DOCTYPE Standards Standards

Determining Current Mode with JavaScript

Like IE 6.0 and Netscape 6+, Opera supports the JavaScript property document.compatMode. When a page is rendered according to Quirks Mode, this property is set to BackCompat, in Almost Standards Mode and Standards Mode it is set to CSS1Compat.

Designing for Quirks and Standards Mode

Quirks Mode enables Opera to display existing invalid pages. If you make pages from scratch, your best option is to make them standards-compliant and use a DOCTYPE to ensure Standards Mode, but see the following Incompatible renderings topic. You may have to add workarounds.

If you have existing pages and they are only tested with Netscape 4 and IE, going for Quirks Mode may be a safer bet initially. If after testing a page looks good in these browsers and in Opera in Standards Mode as well, you may safely change to Standards Mode.

There will not be a complete list of rendering differences of Opera in Quirks Mode and in Standards Mode. This will continously change with whatever standards divergences are common at any given time. The rendering in Standards Mode will always follow the standards. Below are some of the most important differences. They are mostly in one of two categories:

CSS size and position properties specified without a unit

Unit-less numbers in CSS (e.g. ) are interpreted as pixels in Quirks Mode and ignored in Standards Mode.

CSS ID selectors starting with a number

An ID must begin with a letter or an underscore, not with a number (e.g. <div>). Opera ignores such selectors in Standards Mode.

The height attribute in table rows (7.0-7.11)

The HTML <tr> element doesn't have a height attribute. Opera 7.0-7.11 only allowed this attribute in Quirks Mode, Opera 7.2 and later also allows height in Standards Mode.

CSS properties are inherited into tables in Standards Mode

A bug IE/Win and Netscape 4 share is that CSS properties aren't inherited into tables. Opera emulates this bug in Quirks Mode, but not in Standards Mode.

Opera is case-sensitive for CSS class and ID selectors in Standards mode

In Strict mode, class="CLASS" is different from class="class", and the CSS selector *.CLASS will only select the former. In Quirks Mode, case doesn't matter and *.CLASS will match both. Likewise, id="id" is different from id="ID" in Standards Mode, but not in Quirks Mode.

Overriding the DOCTYPE Switch

Normally the DOCTYPE Switch determines which mode is used, but you can set Opera to always use Standards Mode or always use Quirks Mode by setting one of these lines in the opera6.ini file:

If you design Web pages, setting Opera to never using Quirks Mode will help you see how a page will look like in a browser not supporting DOCTYPE switching.

WML 2.0 and DOCTYPE Switching

WML 2.0 uses a special form for DOCTYPE switching. In most respects WML 2.0 is XHTML Basic with some WML extensions and it uses the same namespace as XHTML Basic. In a few cases the WML behavior differs from XHTML, such as the handling of WML variables and $ escaping. See the WML 2.0 Specification for details.

Documentation

gipoco.com is neither affiliated with the authors of this page nor responsible for its contents. This is a safe-cache copy of the original web site.