CSS and the meaning of life_CSS教程

      編輯Tag賺U幣
      教程Tag:暫無Tag,歡迎添加,賺取U幣!
      Wow, my little CSS screed seems to have really hit a nerve. In just six hours it has hit #6 on the Reddit front page (up to #5 now). I didn't even submit it to Reddit because it has been ages since I was able to get any traction over there! All those karma points, they could have been mine. Oh well.

      I would love to respond to all the comments, but the volume is pretty overwhelming. But this one really stands out as my favorite:

      Yes, you are an idiot.

      Why mince words? I confess, I am not a CSS expert. I all but admitted as much in my piece, which is why I based my example on code that was not written by me, but by someone who holds themselves out as being a CSS expert. Maybe I'm so idiotic that I can't even tell a real expert from a snake oil salesman. But I submit that whatever the case, I am an very good company. The mere fact that the CSS wars have gone on for as long as they have is ample evidence that there are a lot of people out there who do not find CSS a model of intuitive clarity.

      I don't want to re-fight the CSS wars here. Instead I want to focus on some things that surely we can all agree on, to wit -- that the CSS wars have been going on for a long time, that a lot of people have put a lot of effort into fighting them, and that very little progress has been made towards resolving the dispute -- and ask the following question: What conclusions can we draw from these observations?

      One possibility, of course, is that one side is right and the other side is wrong, and that the people on the wrong side are simply dim-witted or intransigent, or both. I try (not always successfully) to take seriously the possibility that I could be wrong whenever I write anything. Maybe Dr. Howard R. Fine is right and I really am an idiot. One of the many problems with idiocy is that it does not yield readily to introspection. I take some comfort from the fact that the vast majority of the people accusing me of idiocy don't actually dispute any of the points that I made. But maybe I'm such an idiot that I'm not even worth educating (hard to tell from where I'm sitting). So the best I can do is to leave that on the table as a possibility and move on to the next option, which is, I believe, if it not a more plausible hypothesis, at least more promising as a potentially productive line of inquiry.

      I humbly submit for your consideration the possibility that different people want different things out of life. It seems self-evident, but it can sometimes be surprisingly hard to wrap your brain around the fact that someone else doesn't want the same things you do. One person wants long-term maintainability while another just wants to get it done as quickly as possible. One person wants their web site to be accessible to blind people, another doesn't. One wants SEO, another doesn't care.

      Underlying my conclusion that tables were the way to go was a tacitly assumed quality metric that not everyone shares. At the time I was writing I was not even consciously aware of some aspects of my own quality metric. For example, accessibility to the blind had not even entered my mind. It's just not something I have ever had to deal with, and about which I know next to nothing.

      There are other aspects of my quality metric about which I was aware, but about which I was not explicit. For example, I tacitly assumed that having content spill out beyond the boundaries of its containing DIV is Bad. I think most people would agree on this and other tacit aesthetic judgements that I made, but not all would. A blind person, for example, couldn't care less where on the screen something ended up. (I'm actually guessing about this. I really know very little about how blind people navigate the web. Maybe someone can enlighten me.)

      There are likewise tacit aspects of other people's quality metrics that manifest themselves in their comments. For example, a lot of people seem to think that anything that was done in the 1990's is automatically bad. It is certainly true that tables can be, and during the 90's often were, badly abused. But IMO that is no reason to throw out the baby with the bath water. It's overreactions like that that led to throwing out Lisp with the rest of AI during the 80's, a mistake from which computer engineering is still not fully recovered.

      And then there is one element of my quality metric which seems to be at the heart of the controversy: I believe that computers are meant to serve people and not the other way around. That means that if something inherently simple is difficult to do, it's wrong.

      Not everyone agrees with this. A surprising number of people like things to be difficult. I have never understood this, but it is a fact. Some people revel in the intellectual studliness of mastering, say, C++ template programming or x86 assembler. I don't. I think C++ is a pain in the ass. Life is short, and I would rather spend my allotted time skiing or making love to my wife than worrying about whether or not I need to define a virtual destructor in my base class in order to avoid memory leaks. And that means that when I want, say, for something to appear centered on the screen, I want to be able to do it by typing "center" rather than "margin:auto". If I can't tell a computer to center something by saying "center", then as far as I'm concerned the computer is wrong, not me.

      Like I said, not everyone buys in to this worldview. I don't get it, but it is surprisingly common. I think it might have something to do with job security. I first encountered the complicated-is-beautiful mindset when I was working for NASA. I had an idea for how to simplify spacecraft sequencing and make it less error prone. I figured everyone would love it. To the contrary, the establishment fought the idea tooth-and-nail (and still does to this day). And this attitude is everywhere. It's the reason the tax code is so fucked up. It's the reason the law is so byzantine. It's the reason that languages like C++ and Perl thrive.

      I like simplicity. I think the computer should have to conform to my brain and not the other way around. That's why I like tables. They are simple, and they work -- for some value of "work".

      Different people have different ideas of what it means to "work". For me, the ratio of effort expended to the quality of the visual appearance on the screen is paramount. I want to put forth as little effort as possible to get something that looks decent. (Yes, I'm a lazy bum. It's my greatest strength. Laziness is a powerful motivator for finding more effective ways of doing things, and it has served me quite well.) Everything else is secondary. I don't have any blind customers. I am not in any business where SEO really matters all that much. But your situation, of course, could be different.

      That said, I do believe that some of the things said in favor of CSS and against tables are just flat-out bogus, and to point out some of those was the purpose of my essay. CSS is touted as separating layout from content. It doesn't. Maybe with the new table layouts in CSS3 that will change, but one of the external constraints that I have to live with is that what I do has to work in IE6. While the popularity of IE6 is mercifully in decline, the sad fact of the matter is that it still has a significant market share, and I am not in a position to ignore that much as I would like to.

      Another common thread is that "tables are for tabular data, not layout." Why? Just because they are called tables? Here's a news flash: HTML has no semantics beyond how it is rendered! (That's not quite true. Links have semantics beyond their renderings. And maybe label tags. But nothing else in HTML does.) This is the reason that the "semantic web" is still a pipe dream. HTML was supposed to have semantics, but it doesn't. Giving real semantics to a markup language is really really hard. The history of computer science is lousy with failed attempts, from KRL to SGML.

      Finally, a lot of people pointed to the Zen Garden as evidence of CSS's power. I remember seeing the Zen Garden for the first time and being blown away. But if you look closely you will see that it's not really CSS that makes the Garden beautiful, it's images! Don't get me wrong, the Garden is lovely, occasionally spectacular. But how much of the loveliness is due to CSS and how much is due to photoshop is far from clear. And this is to say nothing of the fact that the Garden completely sidesteps one of the most thorny issues for CSS, namely, dealing with dynamic content. If you know ahead of time what your content is going to be it's not hard to write CSS that will make it look nice. The challenge is writing CSS that looks good if you don't know ahead of time what your content is going to be. The Garden, beautiful as it is, has nothing to say about that.

      I want to point out one more thing: I am not bashing CSS. I like CSS. Its goals are the right ones, and in many ways it is well executed. You can do some really cool things with it, often without having to work very hard. But layout -- at least the three-column layout that everyone seems to want -- isn't one of them.

      來源:52CSS//所屬分類:CSS教程/更新時間:2012-06-13
      相關CSS教程