Doctype html x ua compatible

Using X-UA-Compatible to render websites in compatibility mode.

A compatibility mode is a software mechanism in which a software either emulates an older version of the software or mimics another operating system to allow older or incompatible software or files to remain compatible with the computer’s newer hardware or software.

One of the most common and practical examples of compatibility mode is browsers rendering websites in compatibility mode

Internet Explorer

«Compatibility View» is a compatibility mode feature of the web browser Internet Explorer in version 8 and later. When active, Compatibility View forces IE to display the webpage in Quirks mode as if the page were being viewed in IE7. When compatibility view is not activated, IE is said to be running in native mode.

Origins: IE8

Internet Explorer 8 was promoted by Microsoft as having stricter adherence to W3C described web standards than Internet Explorer 7. As a result, as in every IE version before it, some percentage of web pages coded to the behavior of the older versions would break in IE8. This would have been a repetition of the situation with IE7 which, while having fixed bugs from IE6, broke pages that used the IE6-specific hacks to work around its non-compliance.

To avoid this situation, IE8 implemented a form of version targeting whereby a page could be authored to a specific version of a browser using the X-UA-Compatible declaration either as a meta element or in the HTTP headers.

To maintain backward compatibility, sites can opt into the IE7-like handling of content by inserting a specially created meta element into the web page that triggers compatibility mode in the browser.

A newer version of the browser than the page was coded for would emulate the behavior of the older version, so that the assumptions the page made about the browser’s behavior hold true.

Microsoft proposed that a page with a doctype that triggers standards mode (or almost standards mode) in IE7 would, by default, trigger IE7-like behavior, called «standards mode» (now called «strict mode») in IE8 and future versions of IE. The new features of IE8 are enabled to trigger what Microsoft called the «IE8 standards mode» (now called «standards mode»). Doctypes that trigger quirks mode in IE7 will continue to do so in IE8.

The result for IE 8 Beta 1 was that it could render three modes: «Quirks,» «Strict,» and «Standard.» When there is an old DOCTYPE or when there is no DOCTYPE, IE renders it like IE5 would (quirks mode). When a special meta element or its corresponding HTTP header is included in a web page, IE8 will render that page like IE7 would (strict mode). Otherwise, IE8 renders pages with its engine (standard mode). Users can switch between the three modes with a few clicks. The release of Internet Explorer 8 Beta 1 revealed that many websites do not work in this new standards mode.

Recent changes in IE11

Starting with IE11, edge mode is the preferred document mode; it represents the highest support for modern standards available to the browser.

Читайте также:  Python asyncio run function

Starting with IE11, document modes are deprecated and should no longer be used, except on a temporary basis.

Use the HTML5 document type declaration to enable edge mode:
HTML

If you currently use the x-ua-compatible header to target a legacy document mode, it’s possible your site won’t reflect the best experience available with IE11.

Common/known problems:

If you have already added the X-UA-Compatible meta tag and it’s not working as expected, there could be a couple of factors. See below for a list of common/known issues and their fixes.

IE9 Intranet compatibility mode in Intranet websites

Andrew here explains nicely why IE9 falls back to IE7 mode when running intranet websites and how to properly fix them

Order of meta tags

The X-UA-Compatible meta tag should appear immediately after the tag.

Headers overridden

Check and verify that your application or your webserver is not overriding the headers, because, headers have a higher priority that meta tags.

Invalid W3C

If your HTML markup has invalid content or errors, then websites will not be displayed properly in compatibility mode.

If you are using enterprise version then check the site list. A very detailed list of compatible versions can be found here

TL;DR: Fixes

Add meta tags immediately after the tag.

Force your application or web server to serve with compatible headers. In case of a Ruby on Rails application, you can do the same by adding the following code to your application.rb

config.action_dispatch.default_headers = < 'X-UA-Compatible' =>'IE=Edge' > 

Note that, the HTTP headers have the highest precedence, followed by doctype followed by meta tags.

Источник

Прагма директива X-UA-Compatible

Прагма директива X-UA-Compatible призывает Internet Explorer работать в определённом режиме документа. Остальные браузеры должны игнорировать данную прагма директиву.

Поддержка браузерами

Спецификация

Верс. Раздел
HTML
2.0 Associated Meta-information: META Перевод
3.2 META
4.01 The META element
http-equiv = name [CI].
DTD: Transitional Strict Frameset
5.0 4.2.5 The meta element
5.1 4.2.5. The meta element
XHTML
1.0 Extensible HyperText Markup Language
DTD: Transitional Strict Frameset
1.1 Extensible HyperText Markup Language

Значения атрибута «content»

Атрибут « content » должен иметь значение « IE=[режим_документа] », состоящее из регистронезависимых ASCII-символов. В этом значении должен указываться один из режимов документов, который определяет возможности доступные странице (CSS и JS функционал):

7 Включает стандартный режим IE 7. Тип документа игнорируется.

8 Включает стандартный режим IE 8. Тип документа игнорируется.

9 Включает стандартный режим IE 9. Тип документа игнорируется.

EmulateIE7 В случае, если указан тип документа, включается стандартный IE 7, в противном случае включается режим IE 5.

EmulateIE8 В случае, если указан тип документа, включается стандартный IE 8, в противном случае включается режим IE 5.

EmulateIE9 В случае, если указан тип документа, включается стандартный IE 9, в противном случае включается режим IE 5.

Edge Включает наиболее новый из доступных режимов документа. (Для IE 9 включается режим IE 9, для IE 8 включается режим IE 8.)

Читайте также:  Python exe executable path

Регистр символов: не учитывается.

Источник

HTML5 Doctype, Validation, X-UA-Compatible, and Why Do I Hate Hackers

I’m giving up on HTML validation. FAAK the W3C. FAAK Google. FAAK Apple. FAAK Microsoft. FAAK Firefox.

In the past 10 years, i’ve been quite strict and stern about HTML validation. However, every little thing you do run into problems. In embedding YouTube videos, in adding Google search widgets, adding Comment System, in embedding Twitter or Facebook widgets, in adding ads, in mirroring documents from other sources (for example, Emacs Lisp Manual.)…. Normally, it might take 5 min to do a job. But with concern about correct HTML, it takes n hours to research and find a solution that work across browsers yet still correct. See:

What made the situation worse is that every elite programing idiot (aka “hacker”) will insist on how validation is important and tell you how you should use HTML this or that way, as if reality doesn’t exist.

Worse is that supposedly the “good guys” big companies now peddle HTML5 because it would benefit THEMSELVES, while completely ignore anything about validation. They — in particular the “be no evil” Google — do not even pay lip service to validation.

(Google is trying to overtake the world and run-over Microsoft with the web. They won’t be able do that unless web tech supports traditional desktop functionalities, that’s why they need to push HTML5. Apple do it for the same reason for their iPad iPhone mobile money-cow.)

What is HTML5? It’s a flying-faak-in-your-face against a decade of what W3C told us about what HTML should or should not be. HTML5 was started by mostly Google and Apple, and in the beginning was sneered by W3C, but W3C finally lost the power struggle and accepted HTML5.

You know? W3C is like United Nations. It was supposed to be this neutral standard body. But in fact it really is just a masked face of the powers. The distinction between good for the masses and the powers behind the org, gets thin over the years.

The situation is not much different than the 1990s where the leading companies push new tech to gain market. (for example, Netscape with , , JavaScript, cookies, frames, etc, Microsoft with marquees, Favicon, etc.)

The difference is that this time, the new stuff is sold as a “standard”, and the tech geekers went along applauding.

How to Make Your Site IE Compatible with X-UA-Compatible

What prompted me to write this rant on this topic AGAIN? Well, when i view my site with Internet Explorer 9 (IE9) — this sparkling new, standard-compliant, HTML5-aware browser, it shows a little ugly icon of broken page in the URL field. Curiously, that icon doesn’t show when viewing Google, Apple, or Microsoft sites. So i took a bit to investigate, which inevitably ends up several hours spent.

IE9 broken page icon

The matter is not simple as usual just like every cranny of html/css. But basically, if your site doesn’t include a “X-UA-Compatible” meta-tag, then that icon will most likely show up, even if you use the “html5 doctype” and all your page is valid and pretty simple and doesn’t use any CSS/js/browser-sniffing/quirksmode or whatnot hack.

Читайте также:  Visualstudio microsoft com visual cpp build tools

So my dilemma is, if my completely W3C-valid HTML4 strict site with extremely simple and static markup, do i need to cave-in to whatever some company is doing and add that “X-UA-Compatible” non-standard stupid extra little string just so that IE won’t show that little ugly broken-page icon?

I looked at what other big sites do.

!DOCTYPE html> html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US"> head> meta http-equiv="content-type" content="text/html; charset=utf-8" /> meta name="Author" content="Apple Inc." /> meta name="viewport" content="width=1024" /> meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7, IE=9" /> …

Here is google.com when served to IE9:

!doctype html>html>head>meta http-equiv="X-UA-Compatible" content="IE=8">meta http-equiv="content-type" content="text/html; charset=UTF-8">…
!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">html dir="ltr" lang="en" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml" xmlns:bi="urn:bi" xmlns:csp="urn:csp">head>title>title>meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8" />meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> …

Here is Wikipedia, which does not use the “X-UA-Compatible” and the broken-page icon shows:

!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> html lang="en" dir="ltr" xmlns="http://www.w3.org/1999/xhtml"> head> title>title> meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> meta http-equiv="Content-Style-Type" content="text/css" /> …

Note, Wikipedia is one of the few most trafficked site that uses valid HTML/XHTML, in the few times i’ve checked since ~2005. (but the few times i’ve checked in the past year they seem to have slacked.)

The “X-UA-Compatible” was introduced with IE8. (in contrast to typical tech geekers, i don’t blame Microsoft for it) Here’s Microsoft’s official doc about it: Defining Document Compatibility 2011-04 At Source msdn.microsoft.com

Here is a very short summary. Use one of:

meta http-equiv="X-UA-Compatible" content="IE=edge"> meta http-equiv="X-UA-Compatible" content="IE=9"> meta http-equiv="X-UA-Compatible" content="IE=8"> meta http-equiv="X-UA-Compatible" content="IE=7"> meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7"> meta http-equiv="X-UA-Compatible" content="IE=5">

What is the difference between “IE=7” and “IE=EmulateIE7”?

It’s not clear to me from scanning that long article, but then i found this Microsoft blog: Introducing IE=EmulateIE7 2008-06-10 By Jefferson Fletcher (IE product manager) of ieblog. At http://blogs.msdn.com/b/ie/archive/2008/06/10/introducing-ie-emulateie7.aspx. Quote:

Content Value Details
IE=7 Display in IE7 Standards mode; Already supported in the IE8 Beta 1 release
IE=EmulateIE7 Display standards DOCTYPEs in IE7 Standards mode; Display quirks DOCTYPEs in Quirks mode; Available through the IE June Security Update for IE8 Beta 1

Complexer and Complexer

There is a mantra, widely purveyed among web communities from unix idiots throughout 1990s up to early 2000s.

It’s from Unix’s RFC (aka Really Faaking Common), number seven hundred ninety three, under the section “Robustness Principle”: «be conservative in what you do, be liberal in what you accept from others». Typically quoted as:

This quote was often appended as a pithy quote in sign-off signatures of online postings in web tech forums for over 10 years.

If you ever wonder why web tech is so faaked up, you have to thank these tech geeking idiots. [see The Nature of the Unix Philosophy]

Источник

Оцените статью