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.

121 comments

  1. How did they get the book out so fast by CastrTroy · · Score: 1

    The review states that the book has been updated for IE 7 and firefox 1.5, but IE7 only came out very recently. How did they manage to get the book edited and checked so fast after IE 7 was released?

    --

    Anthropic principle: We see the universe the way it is because if it were different we would not be here to see it.
    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. 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.
    5. Re:How did they get the book out so fast by jfengel · · Score: 1

      People probably do buy the best book they can, but when you're talking about a new technology a lot of people will rush out to buy something as quickly as possible. So while good authors are experimenting and researching, the ones who are just cranking something out are already on the shelves, and the people who rushed out to buy something aren't going to wait.

      In this case, for example, a lot of people probably feel they need something on the new tech so that their bosses can know that they're ready to support it. That can be useful, since it would be nice to know how to fix your old web sites when they break under IE 7.

      I have no idea if this particular book is a good one or a bad one. IE 7 was out so long in beta that there was plenty of time to write a good book on it. In fact there were probably less-good books that were on the shelves before IE 7 was officially released. But writing a good book can be incredibly time consuming. Just coming up with an order in which to present the material involves a deep understanding of the topic.

    6. Re:How did they get the book out so fast by Irish_Samurai · · Score: 1

      Joe doesn't even read. To him reading=audio books.

      I'm not knocking audio books, they have a time and a place, but they weren't meant to supplant reading altogether.

    7. Re:How did they get the book out so fast by duh+P3rf3ss3r · · Score: 1
      IE 7 was in open beta over a year ago


      Sort of lends a new meaning to the word "open", say what? :-)
      --
      Give a man a match: warm him for an instant. Douse him in petrol and set him aflame: warm him for the rest of his life.
    8. Re:How did they get the book out so fast by Doctor+Memory · · Score: 1
      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?

      Probably. From what I've noticed, most average Joes will go to the bookstore to get (say) "a CSS book". They flip through all the CSS books on the shelf, and pick whichever one seems to do the best job of covering whatever aspect of CSS they're trying to get a handle on at the time. Sometimes, they just grab the O'Reilly/Wrox/Addison Wesley/whatever book, because they either trust the brand or prefer the style. Regardless, that's typically the extent of their research.

      I can't say that's bad, because I have wasted a fair amount of time trying to get by with on-line references because my local bookstore[0] didn't have the book that sounded the best, when I could have just gotten any book on the topic and made better progress.

      [0] The one that has a case labeled "Java Development" with a shelf and a half of Java books and four and a half of C# books...
      --
      Just junk food for thought...
    9. Re:How did they get the book out so fast by Sancho · · Score: 1

      Ditto for Opera9.

      I think the issue is that there were substantial, backwards-broken changes to IE7's implementation of CSS. Firefox and Opera were pretty close to correct from the beginning, so web developers don't have to code directly for those versions of those browsers (as much--I'm sure tiny differences exist).

      And that's not even considering that IE has a much greater marketshare than the rest of the browsers, meaning any book which is going to talk about web development really has to discuss getting it right in that browser.

    10. 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... :)

    11. Re:How did they get the book out so fast by smoker2 · · Score: 1

      and since IE7 requires you to validate your copy of windows, who exactly is using it ?

  2. Instant CSS: Just add water. by Anonymous Coward · · Score: 0

    "For every Web site "cook" feeling the heat in their cyber kitchen, there is an ingredient that can help: CSS Cookbook.""

    I'm thinking more "fast food" than cook.

  3. With IE7 I feel like I'm back developing in 1999 by Anonymous Coward · · Score: 1, Funny

    <!--[if IE 7]>
    <link type="text/css" href="stylesIE7.css" rel="stylesheet" media="screen" /
    <![endif]>
    <!--[if IE 6]>
    <link type="text/css" href="stylesIE6.css" rel="stylesheet" media="screen" /
    <![endif]>
    <!--[if IE 5]>
    <link type="text/css" href="stylesIE5.css" rel="stylesheet" media="screen" /
    <![endif]>
    <!--[if lte IE 4]>
    <link type="text/css" href="stylesIE4.css" rel="stylesheet" media="screen" /
    <![endif]>

  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.
    3. Re:Well this sounds promising... by Bogtha · · Score: 1

      The issue with coding is not compliance with CSS standards (those are well published [w3schools.com])

      Please don't link to the sleazy W3Schools when referencing the work of the W3C. They have nothing to do with the W3C and are not responsible for the CSS specifications.

      --
      Bogtha Bogtha Bogtha
    4. Re:Well this sounds promising... by slughead · · Score: 1

      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.

      Non-compliant code is the only way to go.

      Take a look at any complicated JS application. There's bound to be at least one place where things are 'hacked' to work in different browsers.

      I remember when I wrote my first real website and got it to display right in all the popular browsers. W3C's auto-verify went to town telling me my page was a piece of crap... so I 'fixed' it and it only worked in netscape. Outstanding. I restored from backups and have not since verified using w3c.

      HTML nowadays is pretty much the same no matter which browser you use (just prop open table cells with empty images so IE will display right). Javascript and CSS, however, are a whole different story. Try page item positioning in CSS or finding an 'isArray()' function that works in safari.

      I'd like as much as anyone to be able to write a page and not have to verify it in a browser (I know my code's theoretically correct, but it only works as-is 90% of the time).

      In theory there is no difference between theory and practice. In practice there is. - Yogi Berra

  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]>

    1. Re:some improvements for you by Nexcet · · Score: 0

      Why not just....!

      javascript:self.close() /

    2. Re:some improvements for you by Anonymous Coward · · Score: 0

      Serve application/xhtml+xml

    3. Re:some improvements for you by Ant+P. · · Score: 1

      You're missing the [if gte IE 8]!

  6. 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 ;)

  7. 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]
    2. Re:Treat old browsers to plain looking sites. by MikeFM · · Score: 1

      I've never had a client that cared so long as the site was usable for everyone. Most are very happy not to double or triple their costs just to support a few losers who are still using browsers from 1997.

      --
      At what price learning? At what cost wisdom? The price is a man's peace of mind, and the cost is his life.
  8. 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 Anonymous Coward · · Score: 1

      Most commercial websites have to support all incarnations of IE, Netscape, Safari, Netscape, Opera, with the mix of Mac/Windows/Linux, etc. Due to the unfortunate state of CSS compatability among different browser versions, coding with HTML tables is the most universal way of formatting on the web.

      Hence most companies opted for using tables, hopefully that trend is going to change when most people move on to CSS spec compliant browsers.

    2. 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.
    3. 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/

    4. Re:Does any major site use pure CSS? by NoMoreNicksLeft · · Score: 0

      Yes. And people in third world countries defecate in open latrines. Please do not do that either. But if you must do one of these two things, shit out in the open field, it's only slightly smellier, and will go away far faster than a tables-based-layout.

    5. Re:Does any major site use pure CSS? by brianjlowry · · Score: 1

      Also, the major sites that are using table-based layouts aren't redesiging their sites anytime soon either. Have you ever tried to redesign a table-based site? The recommended method involves command prompt and deltree'ing the front-end.

    6. Re:Does any major site use pure CSS? by itlurksbeneath · · Score: 1

      Why is a valid question modded as funny? Anybody got some mod points left, change this to informative (even though, technically, it's interrogative). And to add my 0.02 to the question, it's that people don't want to take the time to figure out a decent design within the constraints of currenly supported CSS. You can do just about any design in CSS you can with tables, but not all of them (maybe 98%). The end result is, of course, smaller, easier to modify and modular enough to take apart and put back together in a different design without having to fight the nightmare of trying to move a table cell in a table without whacking the whole design to hell.

      --
      Have you ever considered piracy? You'd make a wonderful Dread Pirate Roberts.
    7. 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.
    8. 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.
    9. Re:Does any major site use pure CSS? by dubbreak · · Score: 1

      You shouldn't have posted anon (your post might go under the radar).

      I agree with everything you said. I'd just like to add that many people want to look for excuses not to learn CSS. If you are doing a quick one up site, sure do it the quickest way possible (nvu or dreamweaver using tables), but if it is something that is to last the stays of time CSS is soo much more flexible. If you didn't check out the csszengarden link then do so now. All the designs have the exact same html. The only thing changed between designs is the style sheet and images. You can change the entire look of a site w/o changing any of the html or you can have multiple different representations for different presentation media or for different viewers (think of people that have poor vision or are blind for example, cell phone users etc). It's worth learning before you discount its use on a project.

      --
      "If you are going through hell, keep going." - Winston Churchill
    10. Re:Does any major site use pure CSS? by roman_mir · · Score: 1

      You are correct.

      The tables are still a preferred method of laying out information. However DIVs are taking off I think, for example in two of my latest projects we use tables and divs, using table rows to present rows/cols of data and using divs to position portions of the page that are not just records of data. We also use divs inside table columns in one of the project to achieve layout flexibility.

    11. 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.

    12. 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.

    13. Re:Does any major site use pure CSS? by Bogtha · · Score: 1

      It's easier to use something you know rather than something you don't. A lot of web developers are more comfortable with table layouts than with CSS because they have more experience with them, and the stupider, lazier ones use this as an excuse to not bother with CSS. And, because they continue to eschew CSS, they just get more and more experience with table layouts and the problem gets worse. This is only offset by new developers entering the field, the old ones retiring, and the smart ones switching.

      I've been a web developer since the 90s. If I still had to work with table layouts, I'd have switched fields by now. They aren't as easy as their advocates make out; if I had to describe the difference, I'd say that they generate lots of easy work, whereas with CSS you solve a slightly harder problem, but you only have to do it once. Basically, with CSS you work smarter, not harder.

      I'd also like to point out an old saying: "A million flies can't be wrong - eat shit!" Just because lots of people do something, that doesn't mean it's a good idea.

      --
      Bogtha Bogtha Bogtha
    14. Re:Does any major site use pure CSS? by Bogtha · · Score: 1

      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.

      It never did. I distinctly remember when it was first launched, Mike did a couple of interviews saying, in effect, "Aren't standards great!", followed with "We don't actually have to have valid code to be standards-compliant". The whole thing was a PR exercise for the guy to put on his resumé. It was a successful example of separating content from presentation, but that has zero to do with actually complying with standards.

      --
      Bogtha Bogtha Bogtha
    15. 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.
    16. Re:Does any major site use pure CSS? by Bozdune · · Score: 1

      Thank you for writing the comment I would have written. Probably better than I'd have written it, too.

    17. Re:Does any major site use pure CSS? by RedSteve · · Score: 1

      Ah, now that you say that, I recall that. Thanks for the refresher.

      Ah well, at least I could use my incorrect recollection to successfully push for a standards reform at my job... ;-)

    18. Re:Does any major site use pure CSS? by Anonymous Coward · · Score: 0

      Doesn't yahoo.com use all CSS? From looking at the code it looks like all divs to me except one table for the ads.

    19. Re:Does any major site use pure CSS? by coopaq · · Score: 0

      I checked out the link "http://www.csszengarden.com/".

      Question: have they ever heard of contrast?

      I swear if a publisher sold me a book where the gray text blended with the white page I would never buy a book from them again.

      Quality is about usability and when you need to read text you need contrast. This isn't artwork. It's text. To be read.

      I have a LCD and CRT color tuned very nicely btw.

      Here is another site with unreadable text, but very playable artistic games: http://www.ferryhalim.com/orisinal/

      Here is a readable site with nice text contrast: http://www.w3.org/

      Text != Art

      Also those guys who use double spacing... yeah. It's annoying.

    20. Re:Does any major site use pure CSS? by Anonymous Coward · · Score: 0

      Bravo! Someone agrees with me! I was actually beginning to wonder if my reasons for using table based layouts were just a justification. But you're exactly right.

      I love how you describe the nasty hacks as a "laundry list". Why should anyone have to deal with a whole bunch of browser quirks just to make a 2 column layout where the columns are the same height? It can be done very quickly and simply with a couple lines of table code, but takes loads of tweaking in CSS. Not even to mention the fact that because of a nasty bug in IE if the content of your column is wider than the allocated space, you get "float break" where the content area breaks down and ends up underneath the rest of the page. Yes it's possible to deal with these problems, but (IMO) the existing solutions are just plain ugly *especially* when the few lines of table code is pretty darn solid on a large number of browsers.

      By the way, if you visit the #css or #html channels on freenode don't advocate this point of view if you want to keep your head ;-)

    21. Re:Does any major site use pure CSS? by PMoonlite · · Score: 1

      yes; have a look at http://www.redhat.com/ - you'll find some nooks and crannies left from a previous table-based design, but the majority of the site is pure css with not a table to be seen.

      --
      -- Moderation in all things, exceptions to all rules --
    22. Re:Does any major site use pure CSS? by caudron · · Score: 1
      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?

      In part, yes. It is easier to design sites that are formatted as we have grown accustomed to them in the old table layout manner.

      CSS, however, frees the designer from the constraints that table layout imposes. They allow for a great deal more layout freedom and moreover they make it about twice as easy to design sites that are A11y compliant (at least as per the parameters imposed by section 508).

      CSS doesn't do everything well (FFS, why is centering a block element so retarded?!) but overall, it's easier to do many things with CSS than it is to do so with tables---as long as you aren't just trying to reproduce a screwed up table format layout.

      Essentially, it boils down to familiarity. Developers (who are not designers) are far more accustomed to table layout processes than they are CSS layout processes, so they use tables.

      Spend some time getting to know CSS. In the end, it's going to be far more beneficial to your web-dev career than a lot fo other technologies you could be picking up. Especially as A11y and 508 compliance become more important.

      Tom Caudron
      http://tom.digitalelite.com/
      --
      -Tom
    23. Re:Does any major site use pure CSS? by Anonymous Coward · · Score: 0

      I didn't read through the rest of the replies to your comment before posting this, as I need to go offline for a bit, so maybe these have been pointed out.

      Most websites will go with the Tables design over the CSS design. One, many people will use a WYSIWYG editor, like Frontpage or Adobe GoLive. I am not familiar with recent versions of these programs, but the older versions fed you tables as they were not able to display CSS.

      Many design programs, whether at a large university or college, or even a small two week class at the local learning annex will show you tables and Javascript. They do this as it meets the simple requirements for the class and they don't have to spend time going in depth. There are many things that CSS can do and can do more efficiently, but people will instead use Javascript as they either don't know or they don't care. The two I can think of off the top of my head is rollovers and dropdown menus.

      Using a CSS design is typically easier to update if using a linked stylesheet for a large number of pages, or just having it all in a style declaration in the head element instead of on each individual element. I cannot stand seeing tables with font listings on each td element.

      Dial up access: What most people do not even think of anymore is of those that do not have a broadband connection. Using a CSS layout results in a smaller filesize of the main document. I have seen html pages weighing in at over 50KB when using tables and font elements. When redone using CSS and an external stylesheet they drop down to between 5 and 10KB. That is a bit of a difference when accessing the web on a dial up connection. If someone is using a table layout with font elements each page has to be downloaded, and if they were each 50KB then that is a lot of waiting for each page to load. If they were using an external stylesheet and non tables then it would be a quick 7KBish download for each page, and only one download for that external stylesheet. There would still be calls for the stylesheet but it would not be downloaded if it has not changed. And this does not even consider all the images that people use on their pages. Each of those need to be downloaded also.

      So a smaller html file will result in a smoother surfing experience that would be dependent on the user's computer's processing power and not their internet connection speed.

      I still remember surfing the web with graphics turned off on Netscape Navigator. (I also remember using Lynx and still do from time to time.)

      Table based design is a quick and easy way of doing things. A CSS design may take a bit longer to create in the beginning due to browser quirks and such, but in the long run it is a much more elegant way to do things, and you learn a lot more of why things work or don't work in different browsers. Which is always a plus when designing a website.

      If in a hurry and you have not spent time learning the browser quirks regarding a CSS design, then use tables. But if you already know the quirks then stick with the CSS. Besides in a few months, that fourth column in your tables design might need to be moved to the first column, depending on how your CSS is written it may be only a few keystrokes to make that happen on your entire site.

    24. Re:Does any major site use pure CSS? by vjmurphy · · Score: 1

      Before the merger with SBC, AT&T's corporate site used XHTML 1.0 Strict and CSS (tableless, except for data tables and some forms) for its pages.

      For more details:

      http://www.joesapt.net/2006/03/01/00.50.00/
      http://www.joesapt.net/article/weeklystandards/par t1

      Unfortunately, much of that work was pretty much left to die when SBC completed its acquisition of AT&T.

      --
      Vincent J. Murphy
      Spandex Justice
    25. Re:Does any major site use pure CSS? by Anonymous Coward · · Score: 0

      Really? I visited yahoo.com. Using Firefox 2.0 and hitting ctrl F gt;tr and found (starting line 2572) a bunch of table, tr and td tags. Is it you or yahoo that's being weird?

    26. Re:Does any major site use pure CSS? by Lando · · Score: 1

      I don't see anyone else mentioning it, but the csszendarden does not render for me. I'm using the latest Foxfire on Linux x86_64. Any clues as to what the problem might be?

      --
      /* TODO: Spawn child process, interest child in technology, have child write a new sig */
    27. Re:Does any major site use pure CSS? by Lando · · Score: 1

      Nevermind, apparently it takes several minutes for the css to process and come up. Either than or loading external files are taking a long amount of time.

      --
      /* TODO: Spawn child process, interest child in technology, have child write a new sig */
    28. Re:Does any major site use pure CSS? by shmlco · · Score: 1

      That's because the hacks who designed CSS were "purists" who didn't believe in the idea that sites needed layout in the first place. One has only to look at the mess you have to go through to get CSS to do something "simple" like a standard three-equal-length column format with a header and footer to understand this.

      They believed that all web sites should be floating, amorphous blobs of contextually-tagged content, and that "layout" is something one does when dealing with quaint anachronisms like paper.

      It's really the only possible explanation, as otherwise the odds of having so many major decision points totally screwed up boggles the mind.

      --
      Any sect, cult, or religion will legislate its creed into law if it acquires the political power to do so.
    29. Re:Does any major site use pure CSS? by shmlco · · Score: 1

      cssZenGarden is cool, but you need to understand that many of the tricks the various layouts use on don't work on a production site.

      Example: Quite a few layouts absolute position many of the elements... but they can only do this because they know the exact size and amount of text in each container. Do a site with dynamic, variable-length titles and content and those layouts would fall apart.

      Or the way they use background images to do all of the dirty work, which means that many of the layouts won't print correctly if the user's browser has bg printing disabled, and that simple conventions like clicking the "home" logo to go home fail as well.

      --
      Any sect, cult, or religion will legislate its creed into law if it acquires the political power to do so.
    30. Re:Does any major site use pure CSS? by pragueexpat · · Score: 1

      Am I the only one who thinks using floats to create columns is just a hack? Floats, as I understand them, we designed to allow text to flow around a div, picture, whatever - NOT to be used to create columns. If they were, then why does css 3 have a new column layout feature? I, for one, continue to use tables to define columns because I don't like taking elements out of the flow via floats. Does it really matter? Probably not... I don't even know why it matters to me so much - I guess its just the principle of the thing...

      --

      "The prohibition will be strongest when the group is nervous." - Paul Graham

    31. Re:Does any major site use pure CSS? by Briareos · · Score: 1
      many of the layouts won't print correctly if the user's browser has bg printing disabled

      That's what defining different styles for printing using "@media print { ... }" so you get perfectly readable text without any background images is for...
      --

      "I'm not anti-anything, I'm anti-everything, it fits better." - Sole

    32. 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
    33. Re:Does any major site use pure CSS? by Repugnant_Shit · · Score: 1

      Where CSS falls down, and this mostly an IE thing, is with dynamic widths. That Zen Garden page does not, in any of the layouts, resize to fill your browser's screen.

    34. Re:Does any major site use pure CSS? by Java+Ape · · Score: 1
      OK, I'm replying to my own comment, which probably makes me a troll of some sort. Several people have pointed out that CSS degrades more gracefully than HTML, where graceful means the content is still readable, even if the presentation is NOT what the author had in mind. Others object to the use of pixel sizes in my examples. Thus are holy wars begun!

      A good web page should meet three criteria: Utility, accesibility and asethetics. Naturally, these three goals are effectively mutually exclusive, and EVERY page is a compromise between them. If I'm writing documents for computer consumption, XML offers the best utility: clear content divisions, easily parsed, and verifiable with a DTD. Plain old version 2.0 or so HTML runs a close second. However, if the entire web were composed of boring black-and white text, even with nice headers, titles etc. the internet wouldn't be very interesting. And adding graphics and motion and whiz-bang to that text is what brought us active content, graphics, CSS and a host of wildly-unsupported HTML tags, as well as accesibility concerns from those whose hardware or software couldn't correctly display all the new glitz.

      So, when I design a page, I have to ask what the client finds important -- who are they trying to reach and what message do they want to send. Many clients want a very detailed, graphic-intensive, polished look to their site. Ever notice how it's the MARKETING department that's in charge of most web-sites? These guys usually have a handful of highly-paid graphic artists designing brochures and flyers, and they're accustomed to pixel-perfect placement. They rate aesthetics highly, and often don't understand, or don't care, about issues like browser compatibility and the fact that .0001% of the population may be trying to view their site in a black-and-white cellphone. In a perfect world, I should be able to build a glitzy page that pushes the newest graphics card to it's limits with sub-pixel shading and lighting effects, and yet degrades to an optimal display on a palm-pilot, cellphone, or adaptive reader for the blind. I'm not a web-designer by profession, I'm primarily a sysop, so it's entirely possible that I'm missing something. However, I haven't found a way to do this yet (I'm using XML/XSLT to provide several versions of a site). CSS is a powerful tool, which in my opinion, is severely hobbled by browser support (which admittedly is getting better all the time). Naturally, the CSS fan-boys disagree, and assert that CSS can do anything, and when it doesn't display as intended, at least it's readable.

      I submit that, if a client who spent 10k having his graphic artists design a look for the web site, sees that site render in a cell-phone display, he's going to be firing a web-designer, though your milage may vary.

      I am primarily a system administrator, not a web-guru, so it's not improbably

    35. Re:Does any major site use pure CSS? by shmlco · · Score: 1

      Doesn't help. Or, rather, you're missing the point. Since all of the images used are background images, none of them would print in that case. No backgrounds. No accents. No buttons or bullets. No logos. No photos. Nothing.

      --
      Any sect, cult, or religion will legislate its creed into law if it acquires the political power to do so.
    36. Re:Does any major site use pure CSS? by dubbreak · · Score: 1

      That is true. I've had a much easier time doing table based sites that extend to the full width of the browser.

      --
      "If you are going through hell, keep going." - Winston Churchill
    37. Re:Does any major site use pure CSS? by jandrese · · Score: 1

      That's what kills me about CSS though. If you don't specify exact dimensions it is very hard to layout a site. It gets worse when you want a couple of fixed width columns (say a sidebar ad and a menu) and then have the rest of the page dynamically sized to fit the screen. Without using tables this takes some serious CSS voodoo.

      --

      I read the internet for the articles.
  9. CSS isn't "doing it" for me.... by zibix · · Score: 0

    I remember when Flash was the "thing" and everyone went whacky making website completely flash based and how that came crashing down. Now flash is used as an important component of websites. CSS feels the same way to me. Everyone's on the CSS bandwagon. But ultimately it's going to be no more than a really important component of good site design. CSS limits design.

    1. 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.

    2. Re:CSS isn't "doing it" for me.... by Sasha+bee · · Score: 1

      Exactly how does CSS limit design any more than the alternative (not using CSS)? CSS provides much more freedom than writing every piece of style information into your html... What do you propose as an alternative?

      IMO, the nature of the web limits design. CSS is just a way to work within those limits.

    3. Re:CSS isn't "doing it" for me.... by zibix · · Score: 1

      How exactly does anyone interpret my quote "CSS .... a really important component of good site design." as wanting to abandon it?

    4. Re:CSS isn't "doing it" for me.... by shinma · · Score: 1

      Then you don't know how to use CSS.

      There are quite a few designs I've created that I couldn't do with the old table-within-table-within-table sludge and morass we used to have to work with. And they're easily changeable if I have to revamps the look of the site without having to mess with the (properly separated and semantically organized) html or the content in the database. CSS is extraordinarily flexible.

      --
      Shinma
    5. Re:CSS isn't "doing it" for me.... by Anonymous Coward · · Score: 0
      How exactly does anyone interpret my quote "CSS .... a really important component of good site design." as wanting to abandon it?

      Maybe he thought you were being sarcastic.

  10. Sounds logical, but isn't by Anonymous Coward · · Score: 0

    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).

    That sounds logical ... but it isn't. You can write perfectly compliant code which will display correctly in IE6 (a non-compliant browser). The way to do it is to use only those subsets of CSS and XHTML which are correctly interpreted by IE6. IE6 is compliant in many things.

    This may seem limiting but it's a million times better than attempting "browser-sniffing."

    1. Re:Sounds logical, but isn't by 99BottlesOfBeerInMyF · · Score: 1

      You can write perfectly compliant code which will display correctly in IE6 (a non-compliant browser).

      I don't think this is true. You can come very close with IE6 and IE7, but 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.

      The way to do it is to use only those subsets of CSS and XHTML which are correctly interpreted by IE6. IE6 is compliant in many things. This may seem limiting but it's a million times better than attempting "browser-sniffing."

      As I said before, for some applications it is better to use noncompliant code. This is because often the IE supported subset of CSS and XHTML (which is a joke) is insufficient for a given task. Worse yet, IE7 seems to have introduced some new incompatibilities with XHTML in particular, so that XHTML which is not coincidentally also HTML4, no longer gracefully degrades as it did in IE6. So far my project has more or less ignored IE7 (since IE is almost unheard of among our customers), but I expect I will eventually have to work around IE7 as well as IE6 and that might mean moving to browser detection, even for the fairly simple uses I have now. For now though, I see no reason to deprive customers of the advantages of proper CSS and XHTML because a few throwbacks might have problems, so IE users can just suffer with lousy formatting and less ease of use.

    2. 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
    3. Re:Sounds logical, but isn't by 99BottlesOfBeerInMyF · · Score: 1

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

      I'm aware of all the factors you site, but I don't think I've ever gotten such code to work in IE and validate. There was always some weird hack with the scoping or something, which may simply be the validator not agreeing with all the specs, but I'm not really expert enough to judge.

      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.

      Of course not. I can render every character of text as an image or some such nonsense. You never need to use XHTML, it is just much, much, much more convenient if you're taking well formatted XML in and outputting to multiple variants of multiple output formats, like I am. Converting to XHTML and applying CSS is easy and allows the data to be "round tripped" if necessary. Limiting my data to HTML 4 means a lot more complex juggling and the final result has to have information stripped out of it, making it a dead-end in my production system. When I wrote it, I just followed the specs and every browser I tried (sans IE) handled it just the same. Since I don't need to cater to IE users, I'm sure not going to double my work to do so. If MS can't get with the program they can rot (or just get a bunch of poorly formatted and improperly formatted markup).

    4. Re:Sounds logical, but isn't by Bogtha · · Score: 1

      I'm aware of all the factors you site, but I don't think I've ever gotten such code to work in IE and validate.

      Can you give an example? I do this on a regular basis without really thinking about it these days.

      You never need to use XHTML, it is just much, much, much more convenient if you're taking well formatted XML in and outputting to multiple variants of multiple output formats, like I am.

      It depends on your toolset. I'm in a similar situation, and switching between HTML and XHTML is a couple of lines of code. They are both just very similar output formats, after all.

      Converting to XHTML and applying CSS is easy and allows the data to be "round tripped" if necessary. Limiting my data to HTML 4 means a lot more complex juggling and the final result has to have information stripped out of it, making it a dead-end in my production system.

      I'm not following you. Like I said, XHTML 1.0 and HTML 4.01 are functionally identical - you can have <font> and table layouts screwing up XHTML 1.0 just as you can have clean CSS layouts with HTML 4.01. What stripping out are you talking about?

      --
      Bogtha Bogtha Bogtha
    5. Re:Sounds logical, but isn't by 99BottlesOfBeerInMyF · · Score: 1

      Can you give an example?

      Not a specific one due to some NDA restrictions, but basically if you apply scope to the CSS, you need to use a hack or ignore either IE or everything else.

      It depends on your toolset. I'm in a similar situation, and switching between HTML and XHTML is a couple of lines of code. They are both just very similar output formats, after all.

      The problem is contextual information. Say I have some text plus formatting that applies in one context but not another. In XHTML that is fine for any cross product of contexts. For the subset of XHTML that is HTML that means stripping things off and processing different bits before the encoding.

      I'm not following you. Like I said, XHTML 1.0 and HTML 4.01 are functionally identical

      No, HTML provides a subset of XHTML. Picture a matrix of about three sets of branding CSS crossed with six sets of user contexts crossed with eight types of products all resulting in potentially different user visible markup. With XHTML it is just a matter of setting the scope for elements and then applying CSS. All the info is there and you can pull it back out. Also, consider processing the same data to make printed books of the same material, PDFs, and a command line informational system. All this is a lot easier if you can import and export without any data being lost. HTML just doesn't cut it there.

      Sorry about the vagueness of all this but my company is a little hush hush as a matter of policy and I'd rather not come close to having an issue of this thing. I hope this helped explain the type of limitations that make XHTML not limited to HTML a better choice for this application, especially given the fact that IE is mostly a non-issue as it is not used by any of our customers regularly.

  11. Browser Wars by IflyRC · · Score: 0, Troll

    Guess the browser wars are still alive. Hm, competition is supposed to be good for the consumer right? Usually it just means more work for the developer.

  12. Re:Cooking with CSS. by finity · · Score: 1

    What the h*!! is wrong with bacon pizza? I love bacon pizza... Bacon and cream cheese, mmm

  13. Save $0.34 by buying the book at Amazon.com! by Anonymous Coward · · Score: 0

    Barnes and Noble is selling this book for $24.46, but Amazon.com is only selling it for $24.12!

    Save yourself $0.34 by buying the book here: CSS Cookbook. That's a total savings of 1.39%!

  14. A book? by daeg · · Score: 1, Insightful

    A book? on CSS? Why? Do you often find yourself writing CSS without Internet access?

    Personally, the only way for me to know a particular cross-browser CSS approach works is to actually test it on every browser I can. Kinda hard to do that with a book.

    And if these guys were real CSS gurus, they would have written their book in XML and CSS and used Prince to convert it and then open sourced the book code.

    1. Re:A book? by Psiren · · Score: 1
      A book? on CSS? Why? Do you often find yourself writing CSS without Internet access?

      Some people (myself included) just like to sit back and read a book to give themselves some familiarity with the problems before they get down to doing the actual work. This is especially true of a cookbook, which is less of a reference than a source of neat ideas.

      And if these guys were real CSS gurus, they would have written their book in XML and CSS and used Prince to convert it and then open sourced the book code.

      I can't tell if you're being facetious, or you're just a prat. I fail to see why after having writen a book the author should be expected to give away that work.
    2. Re:A book? by j-pimp · · Score: 1
      And if these guys were real CSS gurus, they would have written their book in XML and CSS and used Prince to convert it and then open sourced the book code.
      I can't tell if you're being facetious, or you're just a prat. I fail to see why after having writen a book the author should be expected to give away that work.
      Auctually there may be some merit to his point. I don't think he should give the whole book away. However, Knuth did write his own document processing system to deal with all the math in his books. Perhaps he should give away a chapter or appendix and the index in xml with his own CSS fomatting. He can put it on a cdrom in the back of the book as an alternative. Then the author could say, "I wrote the book on CSS and used CSS to layout the book!!!"
      --
      --- Justin Dearing http://www.justaprogrammer.net/ We're just programmers.
  15. Re:One more time by Fahrenheit+450 · · Score: 1

    Its' doesn't exist.

    Sure it does.
    The book belongs to Samuel Its. It's Its' book; his name is written inside its cover.

    --
    -30-
  16. Re:One more time by Anonymous Coward · · Score: 0

    you forgot 'Than' vs 'Then', but then again, no coder actually writes out > or

  17. Re:With IE7 I feel like I'm back developing in 199 by POWRSURG · · Score: 1

    Conditional comments were first implemented in IE5.

  18. Re: @_@ by Duggeek · · Score: 1

    The reason I linked to w3cschools was to illustrate how CSS is well-published. We all know WHO publishes CSS standards and who is responsible for them.

    Besides, I find content on w3cschools much, much more practical and relevant to my work in web design. Most of the content on w3c.org seem more relevant to browser-app developers. (except for those working on IE7, of course) To their credit, they do have nice tips for beginners; you might want to try them out.

    As to the (thin) implication that w3cschools is the source of CSS standards, I say "touché". (the implication was not my intent) As for your personal issues with w3cschools, I suggest you take it up with them.

    Have some context with your crack... takes the edge off.

    --
    This post © Copyrite Duggeek, all rights reversed.
  19. It's because CSS is stupid. by Mitchell+Mebane · · Score: 1

    No, seriously. I know it must be heresy to say it on here, but, even without throwing IE into the picture, CSS caused me enough headaches to get out of web development. I mean, geez, you can do fancy things, but when the things that are no-brainers with tables take an entire afternoon to do with CSS, you have to stop and wonder what the guys who came up with it were on.

    CSS 3 looks like it might finally be sane, but you know CSS 3-supporting browsers won't be widely for years and years. I don't blame people for sticking with tables.

    --

    The roots of education are bitter, but the fruit is sweet.
    --Aristotle
    1. Re:It's because CSS is stupid. by interp · · Score: 1

      I'm not a native speaker, but isn't style different from layout? Doing layout with a style language always looked akward to me. Which may explain, why it takes an entire afternoon. [Yes, I know it supposed to be used for layouts, but still...]

    2. Re:It's because CSS is stupid. by jandrese · · Score: 1

      Perhaps, but since the other half of your page is the content (which is supposed to have neither style nor layout), you're kind of stuck doing the layout in the CSS.

      --

      I read the internet for the articles.
  20. Re: @_@ by Bogtha · · Score: 1

    We all know WHO publishes CSS standards and who is responsible for them.

    Actually, I see people mistaking W3Schools for the W3C fairly regularly. Whether it is your intent or not, you help promote this misconception when you link the way that you do.

    As for your personal issues with w3cschools, I suggest you take it up with them.

    It's not just me that has a problem with them.

    --
    Bogtha Bogtha Bogtha
  21. 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.

  22. Chapter on 'Styling of Form Elements' by rh2600 · · Score: 1

    Should simply read: Don't

    1. Re:Chapter on 'Styling of Form Elements' by minimalOne · · Score: 1

      why not?

    2. 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 ;)

  23. mod parent doofus by Anonymous Coward · · Score: 1, Informative

    Parent apparently didn't load any of the style sheets.

    Dude, there are TONS of high-contrast basically-eye-gouging styles in which you can view http://www.csszengarden.com/ as well as styles with even lower contrast than the front page default style.

    If you haven't loaded any of the style sheets, you're missing the point of CSS Zen Garden entirely...

    1. Re:mod parent doofus by jamshid · · Score: 1

      That's funny though, I never noticed until that guy mentioned it that most of the sample styles do have really poor readability because of the choice of font and background colors. This is the most readable version: http://www.csszengarden.com/?cssfile=/.

      Is CSS good technology? I guess, yeah separating data from presentation is good. But it sure seems like CSS is overly complicated if it takes this many committees, standards revs, and browser versions to make it usable.

      Maybe if our industry cared as much about separating code (javascript) from data (html), Web Tew Oh wouldn't be so insecure.

  24. Use the right tool for the job by noblethrasher · · Score: 1

    One of the goals of CSS is to separate presentation from content. When I first got into web design, I drank the Web Standards Kool-Aid (coming from a programming background, I can't believe I let myself get suckered into using CSS hacks). I have since come to realize that there are other more efficient ways of achieving that separation without resorting to tableless layouts that require you to spend > 80% of the development time on 10% of the browsers out there. ASP.NET 2.0 master pages go a long way but you can also accomplish the same thing with either simple layout tables , a judicious use of SSI's and/or a good "web language" such as PHP.

    1. Re:Use the right tool for the job by rodentia · · Score: 1


      Or XSL.

      --
      illegitimii non ingravare
  25. 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.

    1. Re:CSS degrades far better than tables by ltrm · · Score: 1

      If I had mod points right now I would be giving them to you. This is exactly point of HTML, if it's written with standards in mind we can reformat it easily regardless of device. Its also worth remembering that CSS support in browsers is only going to get better. Where as table based layout will always have problems associated with them.

    2. Re:CSS degrades far better than tables by WhiteDragon · · Score: 1

      Yes, and it is a great annoyance to me when I try to visit some sites on my Palm (Treo 650) and they totally fail to render. Some sites really look bad. Wikipedia, for instance, with its combination of table-based and css-based layout is unusably bad in Blazer, Palm's default browser. I actually have to put my browser in wide mode (I normally use optimized mode), and try to find the login link on the page, and try to click on it (it's behind the wikipedia logo). Once I am logged in, I have a different default wikipedia skin that renders fine on my Palm.

      That's not even to mention the sites that only work with javascript/ajax (my bank for instance) and have no straight html fallback. I love gmail just because it has a very nice plain html format (of course when I am on a desktop, the fancy AJAX version is quite nice).

      --
      Did you mount a military-grade, variable-focus MASER on an unlicensed artificial intelligence?
  26. ccs: unneccessary complication by Anonymous Coward · · Score: 0

    speaking in my capacaty as a profesional websight develaper i find that css is a useless and unneccessary complication for the vast majorety of websights. seriously, somebody please tell me how:

    <TABLE STYLE="FONT-FAMILY: Zapfino"><TR><TD>some text</TR><TABLE>

    is bettar than the standard:

    <TABLE><TR><TD><FONT FACE="Zapfino">some text</TR></FONT><TABLE>

    css is just another example of netsacpe forscing thier proprietery and nonstandeard languages and ideas on us (along with their equally horrable x.html). css doesnt even run under INTERNET EXPLOER. seriously why make a program that wont even run in the browsar the internet is based on!??!!

    i make all of my websights to microsofts standard html format, often with "Net 2.0" technologies like FLASH and so far i hav yet to see a situation where replacing standard font tags and tables with netscape divs and css could acomplish anything but giving me headaches.

    when i graduate im going to wriet a book on how to make web pages the right way so new developers dont get sucked in by NETSCAPE and their crappy technology

      -// NETLOCKE -//
      [URL]http://www.geocities.com/larkspur10/neo/home. html[/URL]
      THE BEST MATRIX FANSITE ON THE NET!!!

    1. Re:ccs: unneccessary complication by GentlemanRogue · · Score: 1

      I was going to offer a genuine response to this, really I was, and I was going to rip this poor twit a goatse-sized butthole, but then I realized... troll (or else PUI [posting under the influence]) jackass...

      --
      you really expect me to be able to express my opinion of what's so fucked up in this world in 120 characters or less?
    2. Re:ccs: unneccessary complication by Anonymous Coward · · Score: 0

      Hahahaha OP here. Seriously, how the hell could you even begin to write a serious response to that? I don't think I made one true statement in the entire rant. Unfortunately, it wasn't a very successful troll, but I was hoping to give standards nazis a fun target upon which to pour out their sweaty nerd rage. :P

  27. CSS Book vs Web Tutorials by yosofun · · Score: 1
    I remember purchasing a paper-based AJAX book about a year ago. The book was out of date and had a gazillion typos, such that none of the source provided runs without a bit of discerned editing on the reader's part. (Similar dissatisfaction occurred with other paper-based computer books.) Every time, I found that the web provided better tutorials on the matter.

    From the review, I don't see any reason to jump out to purchase the book. Cookbook items are already provided ubiquitously. Even a casual search on google via the general terms "best css tutorial" returns some elegant recipes for free.

  28. Re:CSS is more accessible by Anonymous Coward · · Score: 0

    One of the other reasons for using CSS: to separate content from presentation. I work at a university where all sites must soon be accessible to students with disabilities. CSS is much better than tables, and as some posts have said, CSS will be easier when more people use it more often.

  29. Don't Buy It by WED+Fan · · Score: 0

    Just download it at alt.binaries.ebooks

    --
    Politics is the art of looking for trouble, finding it everywhere, diagnosing it incorrectly and applying the wrong fix.
  30. 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.

    1. Re:Conditional comments are unmaintainable by kchrist · · Score: 1
      You could achieve some middle ground by using a little server-side scripting:
      <link rel="stylesheet" type="text/css" href="style.php?main">
      <![if !IE 7]>
      <link rel="stylesheet" type="text/css" href="style.php?pre-ie7">
      <![endif]>
      <![if !IE 6]>
      <link rel="stylesheet" type="text/css" href="style.php?pre-ie6">
      <![endif]>
      ... and so on (where PHP is replaced by your server-side language of choice). This way you write all your CSS in a single place but still have the ability to conditionally include certain things to fix the various IE bugs.
    2. Re:Conditional comments are unmaintainable by 200_success · · Score: 1

      If I have to resort to server-side programming to generate the CSS response, I might as well do user-agent detection instead. It still means that conditional comments are brain-dead.

  31. Intranet vs. internet by tepples · · Score: 1
    especially given the fact that IE is mostly a non-issue as it is not used by any of our customers regularly.

    In an intranet, you do what works best for your intranet. But most people who discuss web authoring on Slashdot assume, before it is stated otherwise, that a public-facing web site is under discussion.

    1. Re:Intranet vs. internet by 99BottlesOfBeerInMyF · · Score: 1

      In an intranet, you do what works best for your intranet. But most people who discuss web authoring on Slashdot assume, before it is stated otherwise, that a public-facing web site is under discussion.

      I think "customer" pretty much implies "public-facing," don't you? In any case this is not part of an intranet, although the access is limited to partners and those willing to pony up the $40K for our cheapest system. Not that any of that matters as we were discussing limiting oneself to the XHTML that is also HTML4, versus using the fuller capabilities of XHTML where they are called for. My original comment was "it depends upon the application" and I then was asked to explain what application might need those features.

  32. Re:One more time by Paradise+Pete · · Score: 1
    OK, it didn't exist until now. By the same logic, if had written asdfhjweroiudweqqzcax doesn't exist, would you have done the same thing?

  33. table + CSS > CSS by tepples · · Score: 1
    Exactly how does CSS limit design any more than the alternative (not using CSS)?

    There are things that can be done with <table> plus CSS that cannot be done in all popular web browsers with only CSS.

  34. Microsoft isn't "doing it" for me.... by tepples · · Score: 1
    CSS is extraordinarily flexible.

    Until you start dealing with parts of CSS that Microsoft products either ignore or completely misunderstand. The position of <table> advocates in this thread is that there are things that <table> plus CSS can do in IE that CSS alone cannot.

    1. Re:Microsoft isn't "doing it" for me.... by shinma · · Score: 1

      Interestingly, I have not found an instance where my goal was thwarted so completely by IE's noncompliance of standards that I had to resort to even a hybrid table/CSS solution. Generally, there's a known way to spook IE into doing what you need, you just have to find it. And while I understand how that can be a drag, and it can be tempting to fall back on old practices, my experience (and YMMV, of course) shows that the extra time taken to get it right now results in less time taken later to maintain or update it.

      However, I wasn't arguing that tables and CSS don't have a place working together, I was arguing that the poster I was responding to, who essentially stated that CSS will be a passing fad because it "limits [his] design," simply wasn't using it properly.

      --
      Shinma
  35. Re:One more time by TomatoMan · · Score: 1

    No it doesn't.

    http://owl.english.purdue.edu/handouts/grammar/g_a post.html

    The book belongs to Samuel Its. It's Its's book.

    --
    -- http://frobnosticate.com
  36. CSS = useless without full browser support. by Anonymous Coward · · Score: 0

    Sorry but as far as I'm concerned CSS is a dead duck. Until all the major browsers fully support a common standard I'm not going to bother using it. I'm simply bored of all the hacks I have to do to get pages working.

    Sadly it's far easier to put the code directly into the page and to use tables for most layout. This just works and it gives the client what they want in the fastest possible time.

    Most of my clients don't care about accessibility or maintenance. I can hear the cries of horror from the Slashdot crowd but this is business. My clients want something that looks good and they want it now. They don't understand the technology and they simply don't care about the issues. All they're bothered about is whether it looks like they want it to and how much it costs.

    I can do this using all the horrible inline font tags etc. in half the time it takes me to iron out even 20% of the hacking required to get the equivalent effects working using CSS.

    Given that we mostly develop ASP.net applications there's also the issue of the IDE putting in all sorts of crap styling that it's almost impossible to remove. Yes you can do it but again it takes too long fighting against the IDE.

    So I'd love to use CSS, I fully understand why it's a good thing, but I've just lost patience with all the hacking required to get the same effects in all browsers. Every minute spent fiddling with CSS is a minute I could have spent doing work that puts food on the table.

    So I'm sorry until all the browsers support a common set of CSS standards I've given up on it.