views:

154

answers:

5

When you learn HTML and so forth nowadays, the mantra is always "Clean code = better code".

So why do sites like Mobile Me and Google and Facebook all use huge amounts of tables and other not-semantically correct code?

Thanks!

+3  A: 

Because people still use IE6, unfortunately, and it's so incredibly bad at CSS as to make it almost worthless for CSS selectors of any sophistication. Until IE6 is gone and dead dead dead in the cold ground, you're still going to see a lot of this.

If you could see what SharePoint generates, you would probably go into seizures.

Dave Markle
+1 : "IE6! IE6! IE6!" goes the refrain. "A million deaths were not enough for IE6!"
Kornel Kisielewicz
+1, Sharepoint is truly horrendous. I wonder how they can even call it a html web page :/
Alastair Pitts
And the irony is, when it came out, IE6 was the best browser on the planet. I remember laughing about what a crapfest Netscape 4.7.2 was by comparison ...
Robusto
@Robusto: People do tend to forget that. Oh wait, no they don't! It's because they never knew that because they were in junior high school when IE6 came out and now they're in the workforce!
Dave Markle
@Dave Markle: OK, I have a few miles on me. Busted.
Robusto
+1  A: 

Because sometimes that's the path of least resistance. It's not always about being ideologically pure, it's about being pragmatic and getting the job done in this crazy, multi-browser, multi-platform world.

Robusto
+1  A: 

Because it's easier.

While the purist in me will also strive for semantic tags and external CSS for layout, the pragmatist in me need to get this site up by 6pm (so I can go home to my wife and a nice warm dinner!) and there's just this little problem with [insert browser here*] that could easily be solved with a bit of conditional CSS, or a table or something.

There are other reasons for high-traffic sites like Google and Facebook to use inline CSS and js: bandwidth. Every external file you reference is one extra round-trip to the server to fetch. Of course, that doesn't really explain the style="xxx" tags as opposed to just inline <style> tags, but it still reduces the size of the page. Also, while caching does tend to reduce the number of trips, there are still a significant number of requests that are made with a "clean" cache that you still want to optimise for that case.


  • Not always IE (but mostly is)
Dean Harding
It sure is not easier when someone has to come along and change your website later on.
Dave Markle
+3  A: 

Clean code is better, yes.

But working code is much much better )

Davinel
+1  A: 

I had an affiliate marketing client the other day who wanted me to make him a web template where he could go in and edit it with Adobe Dreamweaver (some app I don't use because I'm a Linux user). So, being the web-savvy guy I am, I did it in XHTML with cross-platform CSS that I have learned over the years, using DIVs primarily, and only using TABLES for form field alignment simply because of the 80/20 rule. It was lean code in as few lines as possible, loaded super fast, and worked on all browsers from IE6 on up.

But then I handed it off to him, and he was visibly frustrated and asked me to make changes. He didn't like the CSS because he couldn't cut and paste sections to another page and have the styling carry over. Instead, he wanted me to switch everything to inline styles. Next, he couldn't edit the floating DIVs very well, and would undo my cross-platform work I had done, so he wanted it reverted back to tables. The end result was XHTML + CSS for the shell of the page that centers everything into the middle and adds the fancy graphics around the page. Then, I used PHP "include" separation for headers and footers. The final part was the middle of the page, and that was his domain. I had to compose it in TABLEs with inline styles. At that point, he was happy and I had a compromise.

So, keep this in mind that there are some cases where you have to use TABLE formatting and inline styles because that's all the client really knows how to manipulate.

Volomike