css not work without DOCTYPE ! - css

Is there a way that without DOCTYPE tag all css are working ?

If you don't have a proper doctype, the page will be rendered in quirks mode. CSS will still work, but it will work differently.
What quirks mode mean exactly differs a lot from browser to browser. It has a very big impact on Internet Explorer, as it even uses a different box model.

Not really.
Browsers use the Doctype to determine if they should go into standards (aka strict) mode or quirks mode.
In quirks mode browsers are deliberately buggy so that they are compatible with bad CSS written for ancient, buggy browsers. The results are inconsistent.
It is essentially an intelligence test — is the author of the page smart enough to try to write to standards? If not, assume their CSS is just as bad.
The solution is to write good markup.

You should always try to use a doctype. You don't want your webpages to run in quirks mode, really.

Related

Incoherent HTML behavior in relation with DOCTYPE [duplicate]

In a lot of articles about design, quirks mode is mentioned.
Anybody have an idea about this thing in plain text and in a development prospective?
you can read in this links
:
http://en.wikipedia.org/wiki/Quirks_mode
http://www.quirksmode.org/css/quirksmode.html
http://www.cs.tut.fi/~jkorpela/quirks-mode.html
Modern browsers generally try to
render HTML content according to the
W3C recommendations. However, to
provide compatibility with older web
pages, and to provide additional
"intuitive" functionality, all
browsers support an alternative
"quirks mode".
Quirks mode is not, however, a
standard. The rendering of any page in
quirks mode in different browsers may
be different. Whenever possible, it is
better to adhere to the W3C standards
and try and avoid depending on any
past or present browser quirks.
Generally, quirks mode is turned on
when there is no correct DOCTYPE
declaration, and turned off when there
is a DOCTYPE definition. However,
invalid HTML - with respect to the
chosen DOCTYPE - can also cause the
browser to switch to quirks mode.
More information on the different
quirks modes in different browsers can
be found at QuirksMode.org
Quirks mode means your page is running without a document type declared, the document type is defined at the very top of a page and it denotes how the browser should read the HTML. This is StackOverflow's doctype:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
w3.org specifies web standards and document types, because Stack Overflow uses this doctype it must adhere to the specification of that doctype.
This is HTML 4.01 Strict DTD, which
excludes the presentation attributes
and elements that W3C expects to phase
out as support for style sheets
matures. Authors should use the Strict
DTD when possible, but may use the
Transitional DTD when support for
presentation attribute and elements is
required.
In past days when web browsers did not have full/correct implementations of CSS, developers relied on these idiosyncrasies to make their pages render properly. However, as browsers became more standards-compliant, these pages no longer rendered correctly, as they were written for what bascially was a different type of CSS. This is where quirks mode comes in, as it handles pages written for these broken CSS implementations.
So in 2009, you don't really need to worry about quirks mode unless you're handling older CSS, or older browsers. Just write your CSS to current web standards, and you be OK.
Quirks mode also known as Compatibility Mode - means your page is running without a document type declared(this is old school, so this is most likely not needed anymore)
The whole point of quirks mode is that it's a compatibility mode for IE5. This means that in addition to changing the layout mode, it also switches off most of the browser features that have been invented since IE5.
In quirks mode, the web browser attempts to render/make code based on a ‘best-guess’, this includes a generous interpretation of code that may be non-standard or poorly-formed.
if you don't declare a doctype, the browser will have to guess what version of HTML/CSS you're running
Quirks mode enables older HTML documents to still ‘work
its a technique used by web browsers to maintain backward compatibility with older webpages.
if you write a correct doctype, that will trigger standard mode and not Quirks mode
older browsers like Netscape 4, are permanently locked in quirks mode
Quirks mode enables your browser to behave as if it is an older browser
It's a mode in which the browser is not law-abiding. It accepts any malformed mark-up in this mode and is not strict with syntax, tags and elements
basically means it'll accept your code even if its not-correctly written
In quirks mode, browsers behave as they did in the early days of the web. This was done to prevent old sites from breaking too much in new browsers.
there is a difficulty in writing a page that looks the same in all browsers. In point of fact, that's impossible. Many browsers were written with special features that only they could handle. Or they have special ways of handling things that are different from how other browsers handle them
Using a non-standard will cause every browser to run in quirks mode. But not all browsers behave the same in quirks mode, each browser reverts to its own unique rendering engine which is why it's very difficult to get a page looking alike in different browsers.
also all your html5 css won't work because it won't be compatible
Quirks mode supports the JavaScript functionality of IE6, It is similar to the behavior of IE5 and the Quirks mode behavior of IE6, IE7 and IE8.
in quirks mode, document.body (the body-element) is the root element and in standard mode it's the html-element (document.documentElement).
quirks mode is for the old rules of browsers, they made it so that old websites that were written before the world wide web came and before HTML5 was invented don't break. so quirks mode is just to support those websites that had incorrect CSS features. so now developers had a choice. go with standard (todays browsers) or quirks mode for older browsers and websites. in quirks mode a lot of CSS/HTML features that we have today don't work correctly.
http://www.motive.co.nz/glossary/quirks-mode.php
In quirks mode, the web browser attempts to render code based on a ‘best-guess’, this includes a generous interpretation of code that may be non-standard or poorly-formed.
A web browser may switch to quirks mode if a webpage has no document type declaration or has an incomplete document type declaration (for example, if the URI to the DTD is omitted).
Quirks mode enables older HTML documents to still ‘work’, and should be triggered when the code that has been used is known to fail contemporary technical standards (and when there is no intention/budget to revise legacy content).
In addition to other answers, the mode can be checked by
javascript:window.alert('You are in ' + (document.compatMode==='CSS1Compat'?'Standards':'Quirks') + ' mode.')

How to force intranet sites browser into IE8 Quirks Mode?

I have an intranet site built using ASP.NET that when rendered always displays in standards mode. When using the Developer Toolbar, my site works perfectly using 'IE8 - Quirks Mode'. When using Standards mode it does not appear properly.
I have seen a dozen posts about setting the app into Standards mode (like this one: Override intranet compatibility mode IE8) but these techniques make the browser go to Standards mode.
Does that mean Quirks is the default? If that's the case, my site is not rendering by default in Quirks but rather in Standards.
I also tried this as well and it to makes it in Standards mode:
<meta http-equiv="X-UA-Compatible" content="IE=8" />
What meta tag can I assign or other technice to ensure my site is always rendered in IE 8 - Quirks Mode?
content="IE=8" will make it use IE 8 Standards. To use quirks as far as I'm aware change the doctype as such:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">"
Or leave it out entirely
Firstly, the best thing you can do is try to drop the requirement for Quirks mode. It doesn't just change the page layout, it also switches off all of the modern browser features.
This will give you problems if you want to use any of these modern features. (note that quirks mode is an IE5-compatibility mode, so "modern features" means pretty much anything invented since IE5!). For this reason, I strongly recommend if at all possible that you consider switching the site so it works in Standards mode.
The main reason for using standards mode is to future-proof your code. IE's bad reputation is due to old versions and features like quirks mode, and in recent versions of IE, Microsoft are trying to move away from the past. I would not be surprised to see quirks mode disappear from the browser at some point in the future.
In addition, using standards mode will allow your site to work properly in all other browsers. In Quirks mode, your site will only ever work properly in IE.
The good news is that switching a site from quirks mode to standards mode is often a lot less work than it sounds. The main thing you need to know about is a CSS feature box-sixing. This allows you to use the quirks mode layout model while still keeping the site in standards mode.
Add the following to your CSS:
* {box-sizing:border-box;}
This shuold hopefully fix the majority of the layout issues that you're getting switching from quirks mode to standards mode, and should allow you to stay in standards mode.
The remainder of the layout issues are likely to be caused by bugs in IE5 that have been fixed in subsequent IE versions but left in quirks mode for compatibility reasons. You will probably need to fix these manually. But hopefully there won't be too many of them.
Okay, so if you're still reading, I'm going to assume that the above isn't good enough for you, and you really do want to stick to quirks mode.
Putting a site in quirks mode is fairly easy in IE: Just drop the DOCTYPE declaration.
When IE sees a site that doesn't have a doctype, it automatically assumes that it should render it in quirks mode.
As I say, I strongly recommend not doing this, but if you absolutely have to, that's how to do it.

Doctype and Quirk modes and HTML 5

I am having quite a horrible time. We have a massive site that has no <DOCTYPE> and when I run it with IE10 it goes into quirks mode and after some CSS changes looks ok. As soon as I add echo "<!DOCTYPE HTML>";
The complete site looks terrible and the CSS is not looking as it suppose to. It turns the browser mode to IE10 and docmode to standard. Is there a way to keep HTML 5 functionality but use IE5 Quirks mode or just Quirks mode so the CSS will look correct?
No. The whole point of quirks mode is that it's a compatibility mode for IE5. This means that in addition to changing the layout mode, it also switches off most of the browser features that have been invented since IE5.
Therefore the blunt answer is no, you cannot mix Quirks mode and HTML5. It just can't happen.
However there is some good news for you: switching from quirks mode to standards mode is actually easier than it looks at first glance.
You don't have to go through your whole site changing all the CSS to suit the different box model, because standards mode does have a CSS feature that allows you to use the quirks mode box model while still remaining in standards mode.
Simply add the following to the top of your CSS code:
* {box-sizing:border-box;}
This will change all your elements to use the quirks mode box model, but your page will still be in standards mode.
This should sort out most (if not all) of the layout issues you've been having.
Hope that helps.
No, there isn't. The modern engine that includes the new features and the engine for emulating ancient, buggier browsers are separate entities and you can't mix and match parts of them.
As far as browsers other than IE are considered, you can add tags and attributes introduced in HTML5, without using any <!DOCTYPE>. The page will not conform to HTML5 then, but this is just a formality as such. Browsers do what they do, interpreting tags and attributes as they have been programmed to. There is no “HTML5 mode” in browsers that you would need to trigger with a <!DOCTYPE> or otherwise. Just try it. Throw in some HTML5 novelties like <input type=email> or <details>, and you will see that they work if the browser supports them in the first place, no matter whether there is a <!DOCTYPE> or not.
You would then have difficulties when using a markup validator, but that’s a different issue.
Quirks Mode is a real mess, with dozens of undocumented and poorly documented phenomena. If a page works in Quirks Mode and you then make browsers render it in Standards Mode, literally anything may happen, ranging from no effect to total disaster. So such a change is usually pointlessly risky. Keep using Quirks Mode for old pages developed to use it, and create new pages to work in Standards Mode (and possibly to be HTML5 conformant).
Quirks Mode affects styling and to some extent scripting. It marginally affects the interpretation of some old HTML attributes. But in most browsers, not the way new HTML5 features work.
However, IE is particularly quirky. On IE 10, the above seems to apply. On IE 11 Preview, deviations have been reported. And on IE 9, some of HTML5 novelties that it would otherwise support are not supported in Quirks Mode, such as the canvas element. So if you intend to add substantial use of new HTML5 features to an old page that now works in Quirks Mode, you may need to consider changing the page to Standards Mode first. Depending on the impact of Quirks features, this might be best done by rewriting the page, or it might be “only” a matter of redesigning the use of CSS to conform to CSS specifications.
[Answer corrected Oct 15, 2013.]

Internet Explorer compatibly stylesheet for WebKit?

I am working on a WebKit based browser, but things don't render properly on a IE - only site. Does anyone know of a stylesheet I can inject into these pages to make WebKit render like IE6? Kind of like an anti ie7-js.
I know the proper solution is to make the site standards compliant, but it's not under my control.
Thanks
A good start would be to implement IE's Quirks Mode if no !DOCTYPE is specified. Aside from that you can also support the X-UA-Compatible header to see if the site is designed for a particular version of IE.
Aside from that, there isn't much you can do. It's up to the website owners to decide "hey, we actually want users to be able to use our site" and actually make it standards-compliant.
There are three main things that make IE6 render so differently:
Bugs
Missing features
Quirks mode
You will never be able to (nor should you want to) try to replicate IE6's bugs in newer browsers. IE6's bugs are legendary. You probably have hacks and work-arounds to deal with them anyway, but be glad that you're moving on and away from them.
IE's missing features shouldn't be a problem for you, because your code just won't be using them. Nothing to worry about. Obviously, it would be a problem the other way if you'd written a site for a newer browser, but not for you.
The main point of those three you want to worry about is the third one: Quirks mode is the one that really mangles page rendering in older versions of IE compared with other browsers.
The correct solution to this is to use a valid <!DOCTYPE> at the top of your page. IE will go into standards mode, and will render the same as all other browsers. If your page is designed for quirks mode, then you may have to fix it, but this is probably the right thing to do anyway, and at least the rendering mode will then be consistent between all browsers.
A good doctype to use is !<DOCTYPE html>.
If you don't specify a doctype, then you will have a lot of compatibility problems going forward.
There is one quick way out: There's a CSS feature called box-sizing: border-box. If you set this CSS property in your site, then Webkit and other browsers will switch to rendering the boxes the same as IE's quirks mode.
This sounds like an ideal solution and a direct answer to your question, so what's the catch? As always, the catch is IE. Trying to use box-sizing CSS without fixing the <!DOCTYPE> issue will still leave you with areas of incompatibility, and if you do fix the <!DOCTYPE>, then IE6 won't render in quirks mode at all. It ought to be the solution, but in fact, box-sizing will still leave you with problems to fix.
So I'll say again that the correct solution is to add a <!DOCTYPE>, fix your site and move forward, not try to pull other browsers backward.

Broswser Compatibility Problems. Looks good in Google Chrome but not in IE or Mozilla

I just built my first css website and it looks fabulous in Google Chrome, but after reviewing the site for browser compatibility, I see that in both IE and Mozilla, the site is a MESS. I have no idea what to do. Where do I start to fix the problems?
There can be no specific answer to your question, there could be any reason. The IE should be culprit for the most part; in your case though that doesn't work even in Mozila. Here are some links you may find useful:
Make your site cross browser compatible in 5 steps
The Importance of Cross Browser Compatibility: Tips and Resources
Complete Guide to Cross-Browser Compatibility Check
Cross Browser Compatibility Check Tools
You should be aware of various inconsistencies across browsers especially modern standard compliant ones with IE. There are also some possibilities to use:
Eric's Reset CSS
IE CSS Conditional comments
And finally, it is a good idea to validate your html at W3C just in case.
Since you give no code, there are 3 basic things you can do:
make sure you use a DOCTYPE that is HTML 4.01 or XHTML 1.0: http://www.w3.org/QA/2002/04/valid-dtd-list.html
validate your HTML: http://validator.w3.org/
validate your CSS: http://jigsaw.w3.org/css-validator/
having these will make sure you are using Standard Compliant Mode of rendering, and then if some particular item is not displayed right, you can post specific portion of code to ask about.
First, review your XHTML and the CSS and be sure you are not using anything that is coupled to a browser. See how you have used the styling. I can not give any specific answer as your question is too generic. If you use all standard ways, there will be little issues.

Resources