Slashdot Mirror


CSS Cookbook

Michael J. Ross writes "Anyone involved with the coding of Web sites likely knows that Cascading Style Sheets (CSS) should be used for styling the content of their sites' pages — setting text sizes and fonts, setting background colors, sizing margins, positioning images, and more. CSS allows the Web developer to specify the visual appearance of the site, separately from the HTML, and thus to be able to make changes in the future within a single stylesheet, rather than hunting through the HTML and modifying every occurrence of each affected element. The benefits of CSS are many, but so too can be the frustrations when the developer turns for help to CSS books heavy on theory and light on practical explanations. For every Web site 'cook' feeling the heat in their cyber kitchen, there is an ingredient that can help: CSS Cookbook." Read the rest of Michael's review, CSS Cookbook author Christopher Schmitt pages 538 publisher O'Reilly Media rating 8 reviewer Michael J. Ross ISBN 0596005768 summary Practical solutions to common CSS challenges

Written by award-winning Web designer Christopher Schmitt, this book is published by O'Reilly Media, under the ISBN 0596005768, and is in its second edition, having been updated for Internet Explorer 7 and Firefox 1.5. The book has its own Web page on the publisher's site, offering the book's table of contents, the index, Appendix D ("Styling of Form Elements," in PDF format), and links for reading and submitting book reviews/comments, as well as reading and reporting errata (there are none, as of this writing).

The book's 538 pages are organized into 12 chapters, which cover the major areas of interest to the Web developer: CSS overview, typography, images, page elements, lists, links and navigation, forms, tables, page layouts, printable pages, hacks and workarounds, and design considerations. Appendix A briefly describes some of the better online CSS resources, including tutorials, design guides, discussion groups, technical references, and tools, such as the W3C validators. The next two appendices cover CSS 2.1 properties, proprietary extensions, selectors, pseudo-classes, and pseudo-elements.

The fourth and last appendix, on the styling of form elements, details how 20 CSS properties affect eight form elements, as displayed within Windows Internet Explorer 5, 5.5, 6, and 7; Mac Safari 2; Windows and Mac Firefox 1.5; Windows and Mac Netscape Navigator 7.2; and Opera 8.5. The form elements considered are: checkboxes, file upload elements, radio buttons, text fields, multiple options, select elements, submit buttons, and text areas. The author does not explain exactly what page elements are meant by "File Upload" (at the beginning of the appendix) or "File Input" (the actual section title). Presumably he is referring to the file display field and Browse button, and not the file locator dialog box, which is determined by the browser and operating system. More importantly, he does not explain what is meant by "multiple options" nor "select elements," and neither term is listed in the book's index. Future editions of the book would benefit by beginning every element's section with an example, showing the code as well as the element's appearance on a Web page. Despite this obvious omission, this appendix could prove a godsend to anyone concerned with how these various types of elements are affected by CSS within these eight major browser versions. As noted earlier, the appendix can be downloaded for free.

HTML/CSS books generally fall into two broad categories: Introductory books are usually sufficient for beginners, because they cover the basics. But they are typically useless to the veteran developer who is struggling to understand why Internet Explorer is mucking up yet another page that looks fine in Firefox, Opera, and Safari — and how to work around the problem. Advanced books assume that the reader already has a relatively solid understanding of the technologies, and uses that basis as a foundation from which to explore sophisticated design techniques. But even those books prove inadequate for the developer who is simply wondering how to best use pure CSS to do such presumably straightforward tasks as positioning some images horizontally, with small captions centered underneath each one. In fact, many of those advanced books seem to have little interest in clearly explaining how the reader can do what the author has done, largely because the sample projects and their source listings are too long and involved, thus burying the critical HTML and CSS in pages of code.

There is clearly a great need for one or more HTML/CSS books aimed at the developer who already understands the basics, and wants to apply that knowledge for building robust Web pages, all while following defensible best practices. The O'Reilly "Cookbook" titles are intended to fill that gap, by presenting the material in the form of recipes, each comprising a brief statement of the problem to be solved, a summary of the solution, and a discussion of the solution's details. Oftentimes additional resources are referenced, in a "Sea Also" subsection, which might have one or more links to relevant Web sites. The discussion subsections usually have sample code, in addition to a figure showing the code's output.

Possibly the greatest benefits of the cookbook format, is that it forces the author to clearly state the purpose of each section, and then to get right to the point of how to achieve that purpose. This prevents the meandering seen in many of the advanced design books, which is the main reason why they can be so frustrating for the developer who wants to quickly find out how to perform a specific task on a Web page, such as the image positioning task mentioned earlier. Possibly the biggest downside to the cookbook format is that it results in contrived problem statements, such as the very first one in CSS Cookbook: "Problem — You want to use CSS in your web pages." Is that truly a problem? Is it not much more a goal or task, than some sort of problematic difficulty?

Yet aside from any misleading subsection titling, the recipe format does cause any (largely) expository material in a technical book to get chopped up into somewhat artificial pieces. It is more noticeable in the first chapter of this particular book, titled "General," in which Schmitt explains the fundamentals of CSS: selectors, classes and IDs, properties, the box model, style sheets, comments, shorthand properties, floating images, absolute and relative positioning, and using CSS with the more common page development tools. As the author gets into more advanced topics — for which individual subsections can stand more on their own — the recipe format works fine. One advantage is that the section titles end up being detailed enough that the reader can, in most cases, quickly find the relevant section to address their needs.

Overall, this book is a fine addition to O'Reilly's growing list of programming titles. However, like all books, it is not perfect. It does not cover all of the more common tasks that the average Web programmer might want to accomplish — but it does hit the bulk of them. Sadly, all of the figures in the book are in black and white, including those displaying colors on the sample Web pages. Shades of gray are just not optimal. Fortunately, in most cases, the crux of the technique is discernible. In addition, the sample code has too many instances where layout is achieved using tables, and not pure CSS. Lastly, the book's index — similar to that of so many other technical books nowadays — could certainly use some beefing up. After all, if the reader cannot find the desired material using the table of contents, the index is their last hope, before resorting to time-wasting page flipping.

In terms of HTML and CSS information, the topics are well chosen, and the coverage of browser hacks and workarounds is excellent. Also, the most critical parts of the code are helpfully bolded. For those readers completely unfamiliar with JavaScript, it is used only where unavoidable. The book's material is neatly presented, and the author's writing style is straightforward and approachable.

On balance, CSS Cookbook is to be recommended to any developer looking for a CSS guide that is concise, clearly written, well-illustrated, and addresses the most common challenges in building Web pages.

Michael J. Ross is a computer consultant, freelance writer, and the editor of PristinePlanet.com's free newsletter. He can be reached at www.ross.ws, hosted by SiteGround.

You can purchase CSS Cookbook from bn.com. Slashdot welcomes readers' book reviews -- to see your own review here, read the book review guidelines, then visit the submission page.

27 of 121 comments (clear)

  1. Re:How did they get the book out so fast by Pharmboy · · Score: 3, Insightful

    ...and since FF2 came out before IE7, how did they miss updating for it?

    --
    Tequila: It's not just for breakfast anymore!
  2. Re:How did they get the book out so fast by Anonymous Coward · · Score: 2, Informative

    IE 7 was in open beta over a year ago

  3. Re:How did they get the book out so fast by jfengel · · Score: 3, Informative

    IE 7 had been in beta for a while. They probably had the thing printed up even before IE 7 was formally released, figuring that the last beta would look an awful lot like the final version.

    If nothing else, they'd rather be the first guys in the shelf with an IE 7 book and be wrong than the last guys and be right. An author friend of mine quit writing technical books precisely because she hated losing market share to badly-written books that came out sooner.

  4. Well this sounds promising... by moore.dustin · · Score: 3, Insightful
    In terms of HTML and CSS information, the topics are well chosen, and the coverage of browser hacks and workarounds is excellent. Also, the most critical parts of the code are helpfully bolded. For those readers completely unfamiliar with JavaScript, it is used only where unavoidable.

    Use of hacks? Sweet!

    Hacks are a bad practice that has been challenged and debated for a while now. I though, and correct me if I am wrong, that conditional HTML statements were the best way to go. Nowadays, why would someone want a book that is going to lead you to write non-compliant code.

    1. Re:Well this sounds promising... by 99BottlesOfBeerInMyF · · Score: 2, Insightful

      I though, and correct me if I am wrong, that conditional HTML statements were the best way to go. Nowadays, why would someone want a book that is going to lead you to write non-compliant code.

      It depends upon what your application for the code is. As for why anyone would write non-compliant code, that's easy... most users will be using a non-complaint browser (some version of IE).

    2. Re:Well this sounds promising... by Duggeek · · Score: 3, Insightful

      The issue with coding is not compliance with CSS standards (those are well published) but rather in how the various browsers interpret those standards.

      The code is standard; the parsing and rendering methodologies are not.

      I, for one, appreciate a book that addresses these non-standard behaviors when parsing standard code. The review posted by samzenpus exposes these insights, and contrasts them from the plethora of "standards reference" books. (many from the same publisher)

      Sometimes, hacks are the way to do it. (conditional HTML comments, like CSS itself, are only partially effective) It's not that any, given book leads us to write "non-compliant code", (unless you count FrontPage) but that the differences of current browsers in-use require the "non-compliant" variations.

      In my book, when the page you create works for everyone viewing it, it is compliant.

      --
      This post © Copyrite Duggeek, all rights reversed.
  5. some improvements for you by Anonymous Coward · · Score: 5, Funny

    <!--[if IE 7]>
    javascript:self.close() /
    <![endif]>
    <!--[if IE 6]>
    javascript:self.close() /
    <![endif]>
    <!--[if IE 5]>
    javascript:self.close() /
    <![endif]>
    <!--[if lte IE 4]>
    javascript:self.close() /
    <![endif]>

  6. Re:How did they get the book out so fast by CastrTroy · · Score: 3, Informative

    Do people really buy the first book that comes out, or do they look at reviews and try to buy the best book? It would seem from my experience that a bad book is probably worse than no book at all, since you're getting fed misinformation, or at best spending money on something you're not using. I don't just go to the store and buy the first book I see, I read the reviews to make sure I'm buying the right one. Is this different from what the average Joe does?

    --

    Anthropic principle: We see the universe the way it is because if it were different we would not be here to see it.
  7. The problem with these types of books... by Anonymous Coward · · Score: 2, Insightful

    ... is that it's FAR more valuable trawling the net for information, using forums etc. to get answers than have to to pour through so many pages searching for specific examples or answers to your problems.

    My work got me a few CSS books and when the boss asked if I'd read them, I indicated I'd used them briefly for reference, but no, not as such. He wasn't too impressed until I pointed out the recent sites I'd created, all validated, all exactly to spec and all AA accessible, not to mention extreme light weight CSS which works in *any* browser without resorting to hacks.

    I'm sure it's a great reference point, but the web is by far the most immediate and effective learning medium - I never stop learning and improving my CSS skills, but I don't think a book like this would help me further my skills any quicker.

    The simple fact is that if your looking for very specific requirements and answers, a book will seldom fulfil that goal.

    On the flip side, if your new to CSS and HTML in general and don't have a damn tight deadline, it's worth the purchase.

    For those whose career is web coding, the web itself is the most valuable resource.
    Or, alteratively, if your like me, I prefer reading fiction ;)

  8. Treat old browsers to plain looking sites. by MikeFM · · Score: 2, Informative

    IE7 is compatible with most of the CSS stuff I use at least so usually there are only a few bugs that have to be worked out rather than the tons that I had to deal with under IE6. I suggest just making one standard style sheet that works with Firefox, Safari, and Opera, a IE7 stylesheet that tweaks the minor bugs out, and then a stylesheet for all outdated IE browsers which should make the site usable but plain. So long as the site is usable who cares if people still using IE4 like how it looks? If they haven't cared to update their browser then obviously they don't know the difference anyway.

    --
    At what price learning? At what cost wisdom? The price is a man's peace of mind, and the cost is his life.
    1. Re:Treat old browsers to plain looking sites. by cloudkiller · · Score: 2, Interesting

      Explain your stance to the person/persons paying you to make a super-duper-lookin' site and you will find yourself with one less client. Besides, can you really blame the people who sat down, used IE4 and said, "This is garbage, why would I ever want to upgrade garbage?" In fact, I think we should hold these champions of Windows 95 up as examples. They have been immune to the Windows-upgrade hype since the beginning. Either that or they have just been waiting for Vista for a reaaaaaaaaaaaaly long time.

      --
      [an error occurred while processing this sig]
  9. Does any major site use pure CSS? by pestie · · Score: 5, Interesting

    I'm not trolling, I swear. But I've been playing with Firefox's DOM inspector lately, and I've noticed that every single major site I've visited and "inspected" has used a nested-tables layout. Reading Slashdot will lead one to believe that that's the greatest sin one can possibly commit in HTML design, yet it seems to be done everywhere, all the time. It's my personal opinion that some things are just way easier to do with tables than CSS, and that's why people keep doing it. Am I right?

    1. Re:Does any major site use pure CSS? by RalphSleigh · · Score: 2, Insightful

      Yes, quite right. There is CSS to emulate table layouts, but until I.E supports it tables are simpler, easier and dont require loads of hacks for each browser. Its what happens when you try and use a language designed to describe STYLE for LAYOUT. CSS is great in the cathedral of web standards for styling documents sent over HTTP, however its a little lacking for websites.

      --
      Come as you are, do what you must, be who you will.
    2. Re:Does any major site use pure CSS? by Anonymous Coward · · Score: 5, Informative

      The problem is that like BASIC, HTML is easy to learn by tinkering, without getting a good grounding in the theory. It's possible to write good, elegant BASIC or good, elegant HTML, but there are a lot of total crap tutorials for both that get people started with bad habits early.

      Unfortunately, there are a lot of people with bad habits writing HTML tutorials too.

      One of the big problems is software developers who have a basic grounding in "bad" HTML and use it to lay out programatically generated sites. Developers in general don't want to bother to learn CSS - they seem to think it's the sugar on top - "just" a graphic design thing. So you see a lot of crap HTML work out there - and a lot of table layout.

      For a sublime, pure-CSS experience (make sure and load some of the stylesheets on the right-hand side), check out http://www.csszengarden.com/

    3. Re:Does any major site use pure CSS? by Duggeek · · Score: 2, Insightful

      I'll grant you that tables are often employed to do what cross-platform CSS seemingly can not; yet, there are also behaviors CSS can do that are not possible with tables.

      Yet, I will stipulate that CSS alone can often emulate, or even improve upon, the cumulative effect of rigid-table design. (even without using the DreamWeaver "layer" implementation, though I believe it will ultimately come around anyway)

      The explanation I hear again and again is that Table v. CSS is a "high-road, low-road" paradigm. They both have the ability to get you to the same place, though each takes its own route to get there. I found one such example here.

      For myself, I see that CSS has the room to expand into a complete layout solution.

      The use of tables is dated, and its days are numbered. Tables are just a convenience derived from an element that was intended only to arrange text. (hence the name "table" and not "grid" or "layout") The complications with tables often arise in asymmetrical and non-gridded usage; something tables were not expected to do very often. (note section #4)

      Tables are the old horse, and the scars of being incessantly whipped have been showing for some time. While it's not the same-old way we're used to, CSS layout practices are slowly becoming both more "fashionable" and more common in professional publications.

      --
      This post © Copyrite Duggeek, all rights reversed.
    4. Re:Does any major site use pure CSS? by itlurksbeneath · · Score: 3, Informative

      And, as a followup to your question, the answer is "yes". Check out HP and Yahoo! in a "view source" window. Lots of "div" tags and not any "table" tags that I could see in a casual glance.

      --
      Have you ever considered piracy? You'd make a wonderful Dread Pirate Roberts.
    5. Re:Does any major site use pure CSS? by RedSteve · · Score: 2, Insightful

      ESPN.com had a high-profile conversion in 2003 that was supposed to reduce its load time and file size signficantly. A peek at the front page today shows that, in fact, the site is contained within divs. On the downside, however, it appears that the front page designers have gotten lazy -- currently the page does not validate against its embedded doctype.

      As for why tables-based layouts are done 'everywhere', it could be because of a lot of reasons: no time to do a proper redesign, no desire to mess with a working display, old work habits from developers, not having adequately skilled resources doing the design, or any other reasons that lead upper management to believe that the cost/benefit analysis doesn't demand serious structural changes.

      From my experience, two of the biggest hindrances I've seen to implementing a CSS-based design are making sure that the application developers that work on a site are on board so that their output html validates AND making sure that the html designer knows exactly what kinds of permutations of content might be generated from the applications used on the site. After all, most big sites are really just the results of application output, and without significant planning and design, it's far too easy for developers to fall back on the default output templates that their IDEs *cough*visualstudio*cough* provide.

      As to your question of "It's my personal opinion that some things are just way easier to do with tables than CSS, and that's why people keep doing it. Am I right?", well, yes and no. Yes, it's easier to keep adhering to bad habits than it is to learn new habits. No, it's not any harder to develop alternate and comparable means of display using proper semantic markup and valid xhtml/css. No, I didn't say IDENTICAL designs, I said comparable; some table effects can be done only with, um, tables. But just as a serious print designer would be better served by setting type in an application like inDesign or Quark rather than making one big image file in photoshop, it's a matter of using the right techniques with the right tools.

      That said, I think that the case for coding a proper xhtml/css site is compelling -- bandwidth savings (and improved browser response/user experience), minimal template changes for alternate content delivery, easier path to section 508 compliance, better search engine rankings in google, and forward compatibility are all legitimate reasons to consider using the display methods as they were meant to be used, not as they were hobbled together in the mid- to late-90s.

    6. Re:Does any major site use pure CSS? by Java+Ape · · Score: 5, Insightful
      In my opinion, you've hit the nail on the head. I use CSS-based layouts on my web sites, mostly because it was supposed to be a "best practices" issue, and partially because the inheritance is powerful -- I can make the left menu on every page in the site a top or bottom menu by changing just a couple of lines. However, CSS layouts don't usually degrade well in older browsers: you may see al your elements sequentially, for example. And getting pixel-perfect layouts is STILL problematical. That is to say that I can usually define a left-menu that is, for example 100px wide, and below the header, but it may not be EXACTLY 100 px wide in all browsers, and if I'm nesting multiple elements these little differences can cause big headaches.

      The solution, of course, is to rely on a bunch of hacks to present slightly different rules to different browsers, forcing all of them to display the correct bounding-box, margin, padding etc. And now we're writing unsupported, undocumented nasty hacks that will come back to bite us each time a browser is updated, which as a previous poster pointed out is an obvious no-no.

      Nested tables are not elegant, they're not CSS-based, they're not extensible etc. But they work. A 100px cell displays as at 100 px pretty darn reliably, without a laundry-list of hacks and hints. A menu placed to the left of the content STAYS to the left of the content, it doesn't suddenly display after the content block. From a practical standpoint, tables are simply more robust and more reliable than CSS-based layouts, at least with the flakey browser support CSS layouts have. I've pulled lots of hair out to get my CSS layouts as good as they are, because I believe in CSS, but I think a smarter man would have used tables.

    7. Re:Does any major site use pure CSS? by gfxguy · · Score: 3, Insightful

      I disagree. I've tried to use CSS instead of tables for things like multiple columns and centering, and I can spend hours trying to make CSS look like the table layout that just works on every browser, or I can just use tables.

      Every single CSS methond has some kind of drawback that requires some kind of hack to fix if it's even fixable at all.

      Yes, there's a great deal to be said about separating presentation from content, but like OOP, CSS is no silver bullet.

      They could solve about 99% of the things tables are used for by simply having a "float: center", but even if they did that it would take like 10 years for all the different web browsers to implement it and you'd still be supporting all the old ways, which is why people still use tables.

      Don't get me wrong, I really try and I use the books I've purchased on CSS and website design and online resources including news groups and so forth, and I'd really rather use CSS than tables (and I usually accept a layout that I'm not always happy with just to do it), but this whole "tables are evil" thing will only be true when CSS can do the layouts you can so easily accomplish with tables.

      And contrary to your assertation; the kind of simple "center this" kind of layout I'm referring to doesn't give you a nightmare of nested tables and cells that are hard to figure out where they are.

      Here's an example: a simple centered box that grows or shrinks in width based on dynamic content. A simple unordered list, for example. If the options are small, the entire table is small and centered. If some of the items are wordier, the table automatically grows wider to accomodate the longer list item. If you don't want the table to grow too wide just for the one option (you'd rather it wrap before it gets to 100%), you can put it in a div that narrows the maximum width of the table. In this case, it could simply be a single cell table.

      In CSS, you don't get dynamic width based on the content - you get a percentage width or a specific width. The only way to center it in this case is to use javascript (or you could aproximate it with server side scripting). Believe it or not, after weeks of debate on the CSS newsgroup, that was the answer I got: don't use tables, use scripting to compensate. I'm sorry, but no.

      --
      Stupid sexy Flanders.
    8. Re:Does any major site use pure CSS? by Ed+Avis · · Score: 3, Insightful

      I think the point is that wanting 'a 100px cell' is kinda silly. The size in pixels should always change according to the output device: on a 1200dpi laser printer, making your cell 100 pixels wide will be rather small. Are you _sure_ you always want to specify the exact number of pixels? Isn't it better to give general guidance and let the rendering engine make some of its own decisions?

      --
      -- Ed Avis ed@membled.com
  10. Re:CSS isn't "doing it" for me.... by daeg · · Score: 2, Insightful

    You've got to be kidding me. What do you expect us to go back to, complete table designs and font tags? Should we all switch to static PDF pages since they display correctly in most PDF readers? Not to say that CSS won't be defunct at some point, there currently is no real alternative to CSS.

  11. Re:Sounds logical, but isn't by Bogtha · · Score: 3, Informative

    I don't think it is technically possible to write a completely compliant page that works in both and uses proper CSS and XHTML. I could be wrong.

    You are wrong. There are a few different factors at play here:

    1. Internet Explorer doesn't understand, and thus ignores, many parts of CSS. This doesn't affect compliance because you can usually find another part of CSS that Internet Explorer does understand, to accomplish the same effect. For isntance, Internet Explorer doesn't supprot display: table-cell, which is the easiest method of doing columns in CSS, but you can use floating elements for the same effect.
    2. Internet Explorer misunderstands some parts of CSS. This is less of a problem than it was. You'll get many people complaining about the "broken box model", but this was actually fixed way back in 2001 for those developers that don't trigger "quirks mode". Usually you use hacks - which can come in valid and invalid flavours - to supply alternative code to Internet Explorer. For example, * html #foo { width: 50%; } is perfectly valid CSS, yet is ignored by every standards-compliant user-agent and listened to by Internet Explorer.
    3. XHTML is intended to be served as application/xhtml+xml, which Internet Explorer doesn't understand at all. However, in a compatibility concession, RFC 2854 expressly condones serving it as text/html. Lots of people are confused about this, but the facts are simple if you actually read the specifications. Serving XHTML 1.0 as text/html does not make it invalid, and is completely in line with the specifications. However, all user-agents will actually treat it as HTML and not XHTML. This is by convention, not mandated by the specifications though, and you should not write XHTML expecting it to be interpreted as HTML.

    The anonymous coward was completely correct - it's perfectly possible to use valid code with Internet Explorer by simply limiting yourself to the subset of code that works in Internet Explorer and is defined by a W3C specification. This can be extremely frustrating at times, but it's usually better than the alternative.

    In addition, you shouldn't really focus on the XHTML bit. There are very few people who actually need XHTML, and despite the buzz, it has nothing to do with standards compliance or CSS. XHTML 1.0 and HTML 4.01 are functionally identical in these respects.

    --
    Bogtha Bogtha Bogtha
  12. At a casual glance... by Anonymous Coward · · Score: 2, Informative

    that HP sight uses conditional CSS for IE6, IE5 and IE. So I think hackless-CSS is not here yet.

  13. Re:How did they get the book out so fast by Asztal_ · · Score: 4, Informative

    There's little point. There haven't been many changes in the layout engine from Firefox 1.5 to Firefox 2.0, in fact, these were avoided. Most of the rendering engine changes are going into/have gone into Gecko 1.9, which will become the base for Firefox 3 (There will be an "official" alpha of Gecko 1.9 some time next week, if you're interested). In comparison, IE6 to IE7 is very large difference in capabilities and compliance.

    Not to mention, IE7 came out before Firefox 2.0... :)

  14. CSS degrades far better than tables by ChaosDiscord · · Score: 3, Insightful
    However, CSS layouts don't usually degrade well in older browsers: you may see al your elements sequentially, for example.

    The entire point of CSS is to "degrade well." You've confused "displays identically on mainstream browsers with large resolutions" for actually degrading gracefully. To take a single example I have a lot of experience with, those beautiful table layouts fall apart on small displays. Maybe you can reasonably assume modern laptops and desktops have a resolution of 800x600, but what about my phone (128 x 160) or my Palm (320x480). A table based layout falls apart. But a CSS based layout using floating sidebars degrade reasonably gracefully on my palm. My phone doesn't support CSS and I frequently disable CSS on my Palm for speed. In both cases the CSS based layout may be dull and sequential, but it's perfectly readable. For web sites about presenting useful information this is great. Table based layouts turn into hard to read messes. Now my Palm's browser has a great feature that tries to detect tables-as-layout and linearizes them, and it's pretty good, but it occasionally trashed actual tabular data. Because people use tables to mean two totally different things ("I want this thing exactly here for visual impact" vs "This is tabular data"), my Palm can't try to present a graceful degredation.

  15. Conditional comments are unmaintainable by 200_success · · Score: 2, Insightful

    Many designers would love to use conditional comments if they had CSS block granularity. Instead, the idiots at Microsoft only implemented them at the HTML level, making a maintenance mess.

    Conditional comments would be so wonderful if you could put them in a .css file like this:

    .someclass { position: fixed; }
    /* @user-agent(MSIE < 7) .someclass { position: absolute; } */

    .otherclass { cursor: pointer; }
    /* @user-agent(MSIE < 6) .otherclass { cursor: hand; } */

    That way, the purpose of each MSIE-specific kludge is clear.

    With conditional comments, you would need an additional CSS file for each version of IE you plan to support:

    <link rel="stylesheet" type="text/css" href="mystyle.css">
    <![if !IE 7]>
    <link rel="stylesheet" type="text/css" href="mystyle_pre_ie7.css">
    <![endif]>
    <![if !IE 6]>
    <link rel="stylesheet" type="text/css" href="mystyle_pre_ie6.css">
    <![endif]>

    ... where mystyle.css contains the standard declarations, mystyle_pre_ie7.css contains the first hack and mystyle_pre_ie6.css contains the second hack. That is so impractical that it's not even funny. It's hard enough to work with CSS without having to flip back and forth between all those files to find out which rules apply. God help you if you also have alternate stylesheets.

    It's Microsoft's own fault for producing a browser that needs so many kludges. Their recommended way of managing those kludges is such a joke, they really don't have any right to complain when CSS designers resort to CSS hacks instead.

  16. Re:Chapter on 'Styling of Form Elements' by rh2600 · · Score: 2, Informative

    Browsers tend to do bad jobs at styling forms, mainly because the form elements are part of the OS UI and are painted last by the OS.

    Try styling a form button in Safari. You can't, because Apple have (rightly in my mind) decided that these UI elements are part of OS X's visual vocab and user's know what they should look like. If you try to style a button for other browsers then it's likely it will look horrible in Safari - so then you have to target Safari separately... messy.

    OS X also offers a totally different (and arguably better) file upload form element (which interesting can't really be styled in any browsers anyway). So when you have a nicely styled form, and then drop in a file upload element it looks like crap.

    So if you want a form consistent with the OS interface, and that is consistent amongst all form elements, and across all browsers, don't style it.

    This is all without discussion accessibility and font-scaling issues around styling form elements and using image replacement techniques on buttons. It's not worth the effort, and it breaks in many many cases. You are better off spending time making a more usable form itself, and adding in smart validation and the like ;)