开发者

why do people still use tables, inline css, et al? [closed]

开发者 https://www.devze.com 2022-12-31 20:37 出处:网络
Closed. This question is opinion-based. It is not currently accepting answers. Want to improve this q开发者_如何学编程uestion? Update the question so it can be answered with facts and cita
Closed. This question is opinion-based. It is not currently accepting answers.

Want to improve this q开发者_如何学编程uestion? Update the question so it can be answered with facts and citations by editing this post.

Closed 8 years ago.

Improve this question

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!


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.


Clean code is better, yes.

But working code is much much better )


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.


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)


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消