Design compatibility in IE - html

I'd been designing my website using Firefox 3.up & IE 8 as a reference. I recently happened to see it on IE 7, it looks hideous :[. I thought strict mode was supposed to solve all compatibility issues. I would tweak it for IE 7 but its going to be a hell lot of work.
What do you guys suggest? Should i tweak it for IE 7 or is there another solution to solve the compatibility problems? And how do i avoid such problems in the future? (don't say no one's going to be using IE in the future, but i hope that's true).
The Doctype definition-
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

I thought strict mode was supposed to solve all compatibility issues.
No, just lots of them.
Should i tweak it for IE 7 or is there another solution to solve the compatibility problems?
Yes.
And how do i avoid such problems in the future
Fix them as you go along. Don't leave IE7 testing until the end.

when you develop you should use something like IETester from the start. Every time you make a handful of significant adjustments to the site, you should take a few minutes and test it in all the browsers you are supporting. IETester will let you test IE 5.5-9 in one or two clicks.

There is no magic bullet for IE compatibility. It's the bane of every web developer, and there is no answer to it. You need to be aware of which things work in IE and which don't and try to avoid using the latter, or have a backup plan ready on how to deal with the problems. With carefully crafted CSS you can usually get to 95+% cross-browser compatibility, which leaves you only with a few quirks you'll need to deal with (using IE specific workarounds, graceful degradation etc.). This does take some experience though; until then, test frequently across all browsers!
Welcome to the world of web development. :o)

For layout, CSS would normally do the trick. Use a specific CSS for IE versions that looks hideous using CSS conditional statements:
e.g.
<!--[if IE 7]>
<link rel="stylesheet" type="text/css" href="ie7.css" />
<![endif]-->
See this article for more information. Do not, I repeat, do NOT assume that browsers adhere to all html standards (esp IE). It is a good practice to always test your website using different OS, Browsers and browser versions.

Related

What CSS to fix in different IE Conditional Statement Classes

I am trying to find out if there is a summary for all the css fixes for the classes added (such as lt-ie9, lt-ie8, lt-ie7 etc) in the IE statements as in the code shown in Paul Irish's website: http://www.paulirish.com/2008/conditional-stylesheets-vs-css-hacks-answer-neither/
if there is no such summary, do I fix the css issues (and add those fixes I come across in books/online) after actually testing the browsers ?
<!--[if lt IE 7]> <html class="lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if lt IE 7]> <html class="lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if lt IE 7]> <html class="lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if gt IE 8]><!--> <html class=""> <!--<![endif]-->
A lot of the time, you won't (or shouldn't) need the IE-specific classes. Writing code specific to a particular browser or version is considered bad practice in today's web; in most cases it is better to detect whether the feature you need is supported, rather than checking the browser itself.
This has a number of advantages; the main one is that it frees you from having to learn about all the browser features out there and which browsers support them. It also means that if someone visits your site using another old browser that doesn't have a given feature, your code will continue to work. But it also has advantages for making your code cleaner and easier to work with in the future. There is a library called Modernizr that does a similar thing to the code you quoted, but adds classes according to features supported by the browser. In fact, the same Paul Irish who wrote the code you quoted is also lead developer for Modernizr.
You can check IE's support for various features in various versions in either http://CanIUse.com or http://QuirksMode.org/css/. CanIUse is better for checking newer browser features, but Quirksmode is better for checking the basic CSS features as it has finer grained details.
Many features that are missing from old IE versions can be implemented via "polyfill" scripts. For example, http://CSS3Pie.com/ is a script that adds support for border-radius, CSS gradients and other features to old IE versions. A lot of the time it's better to simply let the browser do its thing and ignore the missing features (eg rounded corners are nice, but the site won't stop working if they're missing), but if you find yourself needing certain features and you absolutely have to support them in all browsers, there's a good list of polyfill scripts here you can try (that list is provided by Modernizr, by the way, so they should all work well with it).
So for the missing features in old IE versions, you shouldn't need the IE-specific classes.
The only time you are likely to need the IE-specific classes is for dealing with browser bugs.
There isn't a definitive list of all known IE bugs (not that I know of anyway), but there are plenty of sites on the web that give details of them and how to deal with them.
First, make sure that IE renders the page in standards mode. If you're in quirks mode or compatibility mode, you may get issues. Avoiding quirks mode in particular will get rid of the worst of the layout weirdness that historically gave IE a bad name.
If you're in the unfortunate position of needing to support IE6, you will need to know about the various bugs it has and how to work around them. There are quite a lot of them, and being able to segregate those bug fixes so they only apply to affected IE versions is important so your IE classes will come in handy.
Later versions of IE have fewer bugs; IE8 is relatively well behaved and frankly doesn't generally require much in the way of browser-specific bug fixes. IE7 can still be problematic though, and IE6 is just horrible. The key here is knowing when you're being hit by a specific bug, and issuing the CSS fix accordingly.
For this, the answer to your second question is: Yes, you just need to test, test, test, and when you see something in whatever version of IE that is weird, you need to investigate it, work out the cause, and if it's a bug, deal with it as appropriate.
Yep, test in each browser, add any thing required afterwards.
There is a service, which may help you to see css features support.
http://caniuse.com/
So you can see which code will make a difficulties in lower browser versions.

Should I use almost standards mode for all browsers?

I am working on a project which requires IE6 compatibility. Unfortunately, IE6 and IE7 do not support standards mode. Because of this, I am tempted target almost standards in for all browsers and just ignore standards mode completely, so that I am only targeting browsers running in the same standards mode. I figure that because XHTML transitional is so popular, almost standards most is guaranteed to be supported for a long time to come. Is this a good idea?
No, this is not a good idea.
Its not a good idea because eventually IE6 will be obsolete (sooner rather than later) and you will have a messed up site where you have to jump through hoops to get it to look halfway decent.
A better solution is to use progressive enhancement, in a nutshell support the minimum you need for IE6 and give the modern standards following browsers the goodies.
With progressive enhancement you still get your support for IE6 but you're left with a standards based website that is easier to maintain and develop further.
Using "almost standards" mode is dumbing down other browsers for the sake of IE. IE6/7 doesn't support a standards mode because it's incompetent. You should never write markup aiming at incompetence. Write modern markup with a strict doctype and use "conditional comments" to hack and beat IE into the best compliance you can get out of that thing or you will be doomed to a world of darkness and hurt.
Roughly 40% of the user base of my company's software uses IE6 (down from ~60% a couple years ago).
Our master pages have the XHTML 1.1 doctype set. I do all my design work using the latest version of Firefox and then once I have it all working how I want, I test in IE6 using the App Compatibility VMs for Virtual PC that MS releases, and make any necessary changes to my CSS that IE6 requires.
Most of the time I can just use slightly different CSS and don't have to resort to hacks, although sometimes I still do. But the hacks don't affect other browsers, since they're IE6 specific. I haven't gone to the length of using browser-specific CSS files yet, cause the extent of my IE6 hacks are something on the order of 10 lines out of ~1500 lines of CSS. My modified CSS to "support" IE6 still renders fully standards-compliant in Firefox.
EDIT: thanks to Rob's comment I'll be changing my doctype to "HTML 4.01 Strict with system identifier" (provided testing shows that it doesn't break anything). That Quirks Mode chart on Wikipedia shows my current doctype (XHTML 1.1 with system identifier and without XML declaration) results in the same render modes.
Everything I said above still applies, though. I code for standards-compliance in the latest version of Firefox (the Web Developer add-on is my friend) and then "make IE work" without breaking standards-compliance in Firefox.

Ie 6, 7 and 8(Compatibility mode) issues

We have a site that works fine with any latest browser including ie8.
But it has lots of issues with ie6, ie7 and ie8(Compatibility mode).
We are using following doctype
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
So it is not using quirck mode.
Before i start digging into individual issues, just want to known if i am missing something or doing something wrong to go ie in some different mode other than standard?
I tried to find list of known issues with ie6 and ie7 when using w3c standards but didn't find much useful, but found just enough to confuse me.
Any known site where i can find known issues with old ie's when using w3c standards?
By specifying what type of HTML document you are using at the top of your document you are taking the browser out of quirks mode. Now, the newer browsers are much more standards compliant and therefore easier to code with. Here are some tips that might help you out:
Use DIV instead of TABLE for layout
Watch out for Document Object Model or DOM differences between browsers
Here is a site with CSS compatibility info: http://www.quirksmode.org/css/contents.html
Run your code through W3C's Validator
Instead of W3C's free validator, consider purchasing a HTML validator which you can run on your machine. In my opinion a programmer wouldn't run a C# program without compiling, and web development shouldn't be done without some sort of validation program. It will save you oodles of time.
Sorry I can't post more links. Stack overflow will only allow me to post one.
Here is one link that has a few fixes I used to use: http://hublog.hubmed.org/archives/001515.html
There are more conflicts and non-implementations than one should ever have to know. If you write standards-compliant websites, your websites will not work in IE6 or IE7. Most people special case IE6 and IE7 with special stylesheets to fix the breakage.
The IE6 PNG fix is especially common.
Here's a good overview of IE related CSS bugs.
Also, if you're not doing it already I strongly suggest you use a CSS reset (here's an example of one CSS reset there are others out there e.g. YUI CSS Reset) - bringing all browsers down to the same baseline and then working up will elminate a lot of inconsistencies without having to track them down individual and hunting for causes if they later appear.
To find out whether you are correctly picking up Standards Mode, enter:
javascript:alert(document.compatMode)
in the browser's address bar whilst your page is loaded. If you get ‘CSS1Compat’ you're sorted. If you get ‘BackCompat’, you're in quirks. This can happen in IE when you've put some stray bytes before the <!DOCTYPE declaration, for example a spurious <?xml declaration.
I tried to find list of known issues with ie6 and ie7
It would be quite long. Yes, even in Standards Mode. Anything in particular?

Formatting good in FireFox, bad in IE.... help

I am a newb for sure. I have been developing in the firefox, and just barely checked in IE. Someone please help me out. Don't know where I went wrong. Thanks!
www.clgproperty.com
"Develop your site using Firefox or Opera. Then test it in IE and Chrome
Don't do inline styling. Use css files.
Continuously check that your design works in these 4 major browsers
Firefox is the best browser for developing websites. Why? Because you can use the FireBug plugin that helps you analyse your html output code and debug javascripts.
Ok, this is all my opinion, but it works for me :)
This is one of the many issues with programming and designing websites. Different browsers render CSS differently (Some are more standards compliant than others). Internet Explorer is notorious for being terrible at rendering CSS.
Your only option is to rethink the design and create a new one that works in both browsers from the get-go, or to use Conditional Comments to include specific CSS for a specific browser, such as:
<!--[if IE 6]>
Special instructions for IE 6 here
<![endif]-->
Start with a strict doctype.
Add this to top of your page (there should be nothing else in front of it, even no whitespace):
<!doctype html>
This way IE will behave according the w3 standards like as the other (decent and real) browsers. This must remove the most of the webdev pains, including the IE box model bug.
As second step, make use of the w3 validator. This isn't the holy grail, but this should spot on the most of the common problems. When fixing w3 validator problems, do it step by step and retest. Most of the subsequent errors are just "sub-errors" caused by one of the earlier errors.
Good luck. And indeed, welcome at the webdev world :)

How do you deal with Internet Explorer?

I am aware that there are probably other questions regarding this topic. I guess that every web developer goes through this with IE.
My problem:
I am developing a web-based application fully based on Javascript. I am a Mac user. I was really happy that everything worked great in Safari, Firefox and Opera. I then asked a friend with Windows to check it with Internet Explorer, and things don't work as well. My application is very sensitive to the HTML standards.
The main problem is the CSS layout. The JavaScript itself seems to be working properly thanks to jQuery for portability.
My question:
How do you deal with Internet Explorer? Should I create a new CSS that is only loaded on Internet Explorer? Should I create a new version of the application only for Internet Explorer? How do you normally handle this? The application is pretty big both in feature design and in layout design.
Edit:
Using the CSS reset as suggested by Nosredna, already removed almost half of the problems. I guess it really is a good practice. I noticed that SO also uses it.
Do you specify a valid doctype? You can get Internet Explorer to be a bit more compliant by switching it into standards mode. http://msdn.microsoft.com/en-us/library/bb250395.aspx#cssenhancements_topic2
Do you use a browser reset CSS file? That can help bring the versions together. http://meyerweb.com/eric/tools/css/reset/
Be aware of IE's CSS bugs: http://www.positioniseverything.net/explorer.html
For the skeleton of your layout, consider using markup that is known to work, such as http://matthewjamestaylor.com/blog/perfect-multi-column-liquid-layouts or http://960.gs/ for liquid or fixed layouts, respectively.
Keep up with JavaScript differences between browsers. jQuery handles some of them, but not all of them. http://www.impressivewebs.com/7-javascript-differences-between-firefox-ie/
Yeah, IE is a pain. If you want it to work in IE, you really want to test in IE every couple days. You don't want to save the pain for the end--you want to handle the nightmares one at a time.
By the way, if you think IE is a pain, try looking at your page with a mobile phone. The other day I went to REI.com with an iPhone and the middle fifth or more of the screen was taken up by a bunch of garbled markup that rendered as text.
Conditional comments.
<!--[if IE 6]>
<link rel="stylesheet" href="ie6.css">
<![endif]-->
<!--[if IE 7]>
<link rel="stylesheet" href="ie7.css">
<![endif]-->
<!--[if IE 8]>
<link rel="stylesheet" href="ie8.css">
<![endif]-->
<!--[if !IE]-->
<link rel="stylesheet" href="normal.css">
<!--[endif]-->
In the IE files, you can use #import to import normal.css, and then override the styles as necessary.
First and foremost, I don't wait until the project is done to consider browser compatibility.
Most of the time for CSS issues there are ways to do things that don't require browser-specific stylesheets to be loaded, so I try to use those solutions wherever possible. For example - if most of your issues are related to box model problems, things like using nested divs in place of padding can help to make sure everything looks correct without the need for separate stylesheets and templates for different browsers.
Browser reset to start. Level the playing field as much as possible and do away with browser defaults. Build your CSS from the ground up. (See: http://meyerweb.com/eric/thoughts/2007/04/12/reset-styles/)
Test early and often across all major browsers during development.
Try to accomplish as much as possible without browser specific hacks. Sometimes you'll need to work in some browser-specific CSS but it should validate (use the W3C Validation tool). Sometimes though there's just nothing for it but a conditional (and maybe even some JavaScript), e.g. fix for transparent PNGs in IE6 (See: http://nettuts.com/videos/screencasts/5-easy-ways-to-tackle-ie6s-transparency-issues/).
If you cannot run IE on one of your development machines, try http://browsershots.org. At least you can get some feedback this way.
Use a debug.css that highlights or outlines divs and other elements. Toss this into your HTML head if needed during development. This can be a huge help.
Use "developer toolbars" where available (IE, Firefox).
EXPECT THAT IE IS GOING TO BE A PAIN, and TEST IN 6, 7 and 8.
Have fun!
Here is how I try to reduce the pain of dealing with IE:
Use a reset.css - Yahoo! YUI Reset or Eric Meyer's Reset CSS
Be careful with floats, clears - they typically cause a lot of cursing.
Be aware of hasLayout bugs in IE, typically adding a zoom: 1 or height attributes helps fix this. Read On Having Layout.
Get the layout working in Firefox, Safari, Chrome, etc while keeping IE about 80% of the way there.
Implement a IE6.css style and an IE7.css style if needed using conditional comments.
Beer, Liquor or other adult beverages.
First, read On Having Layout, which explains how the IE rendering engine works internally. IE's rendering engine is from before CSS. It doesn't properly distinguish between inline and block elements like you'd expect. Instead, in IE an element hasLayout. Or not. This is the source of 99% of IE CSS bugs. So, read that article a couple of times.
As for fixes, I usually use conditional comments. Several reasons:
They are future proof, as opposed to CSS hacks. What if IE9 fixes the hack but not the bug you're using it to solve?
It's valid (X)HTML (conditional comments are just plain comments to everyone else)
It doesn't require javascript. You'd be amazed how many people have javascript turned off.
One remark about conditional comments: Never use an open ended match. That is, never do something like:
<!--[if IE]> <load css> <![endif]-->
<!--[if gte IE 7]> <load css> <![endif]-->
The reason is the same as hacks: make it future proof. What if the next version of IE fixes the bug and you don't need the fixes anymore? Or worse, the "fix" now actually messes up your layout in the new IE version? It's usually best to assume that the next version of IE has fixed the bug that you are working around. I have written a little bit about that back when IE 8 was on the horizon.
I think it would be okay to write a specific css file for IE. I know it is a pain, but because of some possitioning issues, IE6 looks different than all other browswers.
Use this line for your newly created css file:
<!--[if ie6]><link rel="stylesheet" type="text/css" media="screen" href="ie6_style.css" /><![endif]-->
With IE getting around 65% of the traffic, I don't think you can think of it as an after-thought.
Overall, I try to do as much as I can without making a separate CSS file for IE. I'll use come conditional formatting to target it specifically if needed. Overall though, at most you might need to do an IE only stylesheet to get it to work.
Just be sure that you are testing with the proper versions of IE for your audience, as IE 6, 7, and 8 are quite sommon.
As a last resort, when tweaking the CSS just won't fix things, I like to use Rafael Lima's CSS selector script. While it depends on JavaScript (most sites I build do anyway), it provides a convenient way to tweak CSS for different browsers and versions without separate stylesheets.
You can have :
.someClass {
margin-left:1px
}
.ie6.someclass {
margin-left:2px
}
<script>
if (internetExplorer) {
window.location = "http://getfirefox.com";
}
</script>
Keep the markup as simple as possible. Make small changes. Test every change.
I delete it
I would think that developing a new CSS File for use in IE would be considerably easier then re-writing your application, but I don't know what scale and scope your application has that would even render doing that a considerable option. I guess it can depend on what versions of IE you're looking to support.
We're at a point now that most users should have completely migrated away from IE6. IE7 is still a hassle, but nowhere near as bad as 6 was. With my projects, the default setup I sell is IE7 compatibility with code to direct users of IE6 and below to upgrade. If a client wants me to incorporate IE6 compatibility into a site, I typically increase the quoted price by 50% because of how awful of a headache is is to support the browser and how much extra visual code has to be written to make it work.
I know that this may fall into the 'too little, too late' category. That said, I would investing in VMWare or Parallels and create a Windows VM w/ IE6.
As you are developing, you should incrementally check your progress in the browsers that you care about.
That said, with an existing application, I would first make sure that my HTML was valid (there are a variety of validation services at your disposal) then, depending on the layout, I was section-by-section try to get the layout right, using comments to 'hide' the sections that you are not actively working on.
I usually do everything I can to avoid having to create a separate CSS file. There are a lot of CSS & HTML tricks & tips out there that should allow you to make it work in IE6 & up, as well as every other common browser. It just takes time to figure it all out. Unfortunately, sometimes with complicated layouts it can take a lot of time especially when you don't test it as you go.
I let others solve the problems for me. I use Yahoo's excellent CSS files included in their YUI library. They have one file to remove existing formatting for existing labels (e.g. H1 in IE does not look like H1 in Firefox), they have another to give me a default set of formatting that does look the same across browsers, they have yet another to standardize font sizes, and most important of all of them is their grid file. It gives me the ability to build hierarchical formatting of regions and sub-regions on the page very quickly and easily and I know it will work on any major modern browser (Yahoo tests the heck out of it to make sure it does).
It may not be the perfect solution, but it has been more than sufficient for my needs.
I had the same issue in my dev: IE6, FFetc + LAMP + custom MVC, based on Rasmus Lerdorf's article way back when he suggested noMVC-kind of like handle it using includes for headers, footers and the sort. I coded CSS, got stuck with FF not rendering it nicely. I had to go revise my CSS knowledge - I found that a single CSS implementation can render correctly in std. compliant mode(FF) and IE6. I liked that. I was happy with handling any changes using a single CSS file. My advice:
I know you have a Mac, go garage sale-ing (newspapers will tell you where they are), get an old PC for $10 (so far I've found plenty). This'll give you an opportunity to test out IE6 early, while you're at it get a KVM switch as well to access the machine when you need to.
One of the things I've gotten addicted to is IE6's setting - Disable all ActiveX scripts - makes browsing the web without ads a blast, anyways - test out your app with & without activeX settings, and see how well your site does. This has literally saved me hours of 'painful' moments folks above me have mentioned prior.
You prolly know how to test out FF/Opera/Safari with&without scripting
Finally - regardless of how heavy Javascripting your site uses, make sure without scripting the core features (which I'm sure you have lot's of) load properly.
I'm no expert, but sure hope my comments help you out a bit.
Cheery-O
I make sure my websites work natively and perfectly in ie9 , and work in ie8(possibly with features missing).
I prompt everyone that uses an older version to get chrome frame.
I never waste my time for ie7 and older, because using a 6 year old browser is pathetic, and should not be encouraged.
As nosredna said, use a valid doctype (see http://www.alistapart.com/articles/doctype/)
Then check your web site in the w3c validator (http://validator.w3.org/). If it shows no errors (or just a few), then IE should render it correctly.
I wouldn't put much effort in making it compatible with IE6, and just accept the fact that a website can look different in various browsers.