views:

110

answers:

4

I'm trying to motivate my team members to get our code to validate, but there seems to be some disillusionment because we are required to still support IE6.

Do you guys have any thoughts to this end?

This is what I'm going for:

  • Semantic code - YES
  • Validating code - YES
  • Works in IE6 - YES

Let's not argue over semantics here lol. =]

HTML JS CSS

A: 

No, it is not possible for any moderately complex layout.

EDIT: At least not without adding lots of ugly conditionals.

Rob H
Remember, valid code and semantically correct code are two different things. When do you ever have to supply IE6 with invalid code to get it to work?
Doug Neiner
Ugly? conditionals are the preferred way to support IE browsers. CSS hacks are not only ugly, but often invalid hacks to get IE to cooperate.
Doug Neiner
I interpret the question to mean whether one can write standards compliant HTML/CSS and achieve a consistent layout on IE6 and more modern browsers. Perhaps I'm reading too much into it.
Rob H
+11  A: 

Yes, you can have fully compliant code, and keep the cruft for IE6 in a separate file (normally):

Just hide any IE6 specific code with IE conditional statements. This is the preferred way to do it if you want your CSS to still validate. Additionally, all valid HTML should work fine in IE6 with the proper styling applied via CSS:

<!--[if lte IE 6]>
   <link rel="stylesheet" href="/css/ie6.css" type="text/css" media="screen" />
<![endif]-->

That will be hidden from all validators, and the rest of your code can remain valid.

In fact, since the conditional comment is just that, a HTML comment, even that code is still valid.

EDIT:

The only way to prove this would be to build an example, but all three are possible with IE6 and proper knowledge in coding.

  1. Semantic Code: YES
  2. Validating Code: YES
  3. Works in IE6: YES

In fact, its not just IE6 that presents a problem with valid code but both IE6 and IE7 (and IE8), but again, only in the CSS. Validate your main CSS files but keep IE6 CSS separate with conditionals.

Rarely do I have to add extra markup to the HTML to support IE6 (other than conditionals in the head). It is simply a matter of understanding the box model, and building your semantic pages accordingly.

One or two divs are not evil if they present a proper grouping. Three nested divs to fix a bug is evil :)

Doug Neiner
Great point. Conditionals work great. I really want our site code to validate AND be semantic as well. Let's see if we can do it!
codeninja
Keep in mind that conditionals are only part of the solution. Furthermore, with the rise of HTML5 and css3, user experience is going to vary more widely between standards complaint browsers and IE6/7. http://dowebsitesneedtobeexperiencedexactlythesameineverybrowser.comis a great example of how to degrade gracefully, and it's witty!
Jack
+1  A: 

It's a bit of work to make the code work in IE6, and there is a bit of work to make the code validate, but that doesn't mean that it's the same kind of work or that one of them will make the other impossible.

There isn't really anything that says that the code has to fail validation to work in IE6. On the contrary, code that validates is more likely to work in any browser, not just IE6. There are some IE6 quirks that you can circumvent using non-valid code, but it's not the only method for circumventing the problems. Methods that use valid code are also more likely to continue working when new browser versions are released, so that you don't have to start over for every new browser update.

It's of course easier to make the code work in IE6 if you don't have to think about valid code at the same time, but that's just because there are more factors to consider, not because the factors are incompatible per se.

Guffa
+4  A: 

Short answer: yes!

It's been my experience that valid, semantic markup actually works better with IE6. Combine this with correct, valid, and simple CSS and you're pretty much golden. Sure you're bound to encounter some strange behavior in IE6, especially for more complex designs, as noted above. However, most of these bugs are well documented. With simple, valid code, identifying and fixing these issues is often fairly simple.

Conditional comments, as noted above, certainly work, but developing valid code will prevent you from peppering your code with all sorts of conditions.

Still can't make it work? Degrade gracefully! Sure rounded corners are pretty and all the rage, but the 20% (hopefully less) of your users who are still living in the dark ages probably won't miss them.

Jack