2007-02-08

CSS Hacks, browser updates, and the Holy Grail

CSS Hacks generally work in one of the following ways:

  1. Hide CSS that is rendered buggily from the offending browser, using perfectly valid code read by (all) other browsers
  2. Feed CSS 'corrections' to a browser that only it needs, exploiting valid, but nonsensical code that all other, standards-compliant browsers will ignore.

In a perfect world, where browsers that correctly parsed valid CSS also correctly rendered 100% of CSS, hacks would be safe.  Hacks are also safe against browsers that are 'dead' (no longer supported or developed).  But dead browsers should eventually die out and disappear, right? Well, they should still be taken into consideration. My simple amateur solution is to hide as much CSS from such browsers as I can (wholesale, using an @import 'shield'). I find it ironic that some 'dead' broswers are more commonly used than new ones, but that's a different matter.

The problem with hacks arises when they backfire. The following conditions could cause hacks to backfire:

  1. A browser is updated that correctly renders the CSS, but does NOT parse the code correctly.  This is ok, as the browser is still fed rules that are 'safe', from a design point of view: it's not the full design, but it's a baseline that works.  It worked before, and will continue to do so, unless new rendering bugs have been introduced.  
  2. A browser is updated that correctly parses the CSS, but does not fix all the (well-known) rendering problems.  This is problematic and what I would call a 'backfire'.  This is exactly what ppk warned us about back in 2003.

I say all this again because of my frustrations from the following:

  • The point of standards is t not have to worry about differences in implementation: a 'standard' should apply to everything that subscribes to it.  This is not the case with CSS, sadly, even 10 years after it's introduction.  
  • I want to write CSS code and design layouts that conform to the standards.
  • BUT, the single-most popular browser out there remains, unfortunately, Internet Explorer for Windows.  Because it comes conveniently bundled with the most popular operating system for average computer users.  Because most of those users don't know there are better alternatives, and they don't care.  And when they visit a site that looks garbled, they blame the designer, not the browser.  Perhaps they should, at least in part, but it is very frustrating for amateurs who want to put up their own web page, and may even have some neat design ideas, but get frustrated by how difficult it can be to accomplish.

Yes, I am frustrated.  Every time I dip my brain back into this world, I get frustrated by these facts.  I have come to loath Internet Explorer and resent it's simultaneous popularity and bugginess.  I sometimes consider giving up, using a stock design, and not wasting my time worrying about it.  But, I'm stubborn, and a bit of a perfectionist, even when it comes to my hobbies.  "If you can't learn to do something well, learn to enjoy doing it poorly".

All this leads me to my point here.  My usual approach has been to design to standards, use as much clean code as possible (without going mad with testing), and only worry about the most common browsers that I can easily test in: the rest don't get to even see the layout CSS code.  Yes, I use a Mac, because I have yet to find a better alternative that just works (I'm less of a fanatic than I used to be, but I still think it's the best alternative I've seen).  As such, I generally test in Firefox, because I like the de-bugging features it has (DOM tree inspector, better code view, error reporting, etc.).  I also test in Safari, because I actually use that most of the time for browsing, and it's fairly standards compliant, albeit a little idiosyncratic at times.

But eventually, I have to resign myself to test in IEwin (that's Internet Explorer for Windows). *sigh* So, I usually add the 'fixes' to the code to make it work in IEwin, but these are generally corrections that I hide from other browsers using CSS hacks: the star-html hack (and more complex offspring, the 'modified Simplified Box Model hack'), and occasionally the child selector.  The star-html types of hacks follows the second approach I mentioned at the start, while the child selector follows the first.

This used to be safe, until Microsoft started working on IE version 7, and decided to be more standards-compliant.  This is good news.  However, they regretfully decided to fix the parsing behaviour, without fixing the CSS rendering problems.  Now, the hacks may backfire!  gah!  I'm going to take a moment to complain about this decision and respectfully suggest that browser makers follow a few simple rules when updating the browsers:

  • Fix the rendering bugs first, then the code-parsing problems.  It's safer to implement something before having multiple ways of triggering it.
  • When fixing the code-parsing bugs, add support for CSS declarations before removing support for quirky ones.  The decision to remove IE7's recognition of the star-html selector has caused endless code-rewriting for people who have used this hack.  Adding support for things that weren't recognized before is good and responsible.  Adding support for the child and other selectors allows IE7 to do a bit more: hacks that fall under the first approach above will backfire, but it also opens new possibilities and makes these selectors more broadly useful than a simple browser shield.  This also means the second approach to CSS hacks should be safer (if this rule is followed).  Otherwise, lots of 'corrections' end up rotting in stylesheets and never get to the user agents that need them.  Ideally, removing support for quirky code shoudl be done after fixing the rendering issues first.

Perhaps the best approach after all was to move all IE-related statements to a separate stylesheet and feed it to IE using code in conditional comments.  This makes style-switching a bit more complicated, but rock-solidly reliable for design & walk-away sites.

I admit, I was / am lazy.  I don't have time to test things endlessly, fix, then clean up afterwards.  I'm an amateur, I like doing this in my spare time, and I want simple solutions.  Then again, if it were that easy, lots of professional web designers would be out of work.  But, surely, there must be a place for amateur designers, without having to lose too much sleep or feeling overwhelmed by the miasma of browser incompatibilities.

Perhaps, I should study compatibility tables more often before committing to a certain CSS approach, and only use 'safe' methods, and no hacks.  But that can take a lot of work, and would require changing how I approach CSS coding, and restricting myself to a potentially tiny subset of well-supported methods.  My challenge, and humble request, to the standards-based webdesign gurus, is to spend a little time describing such safe methods, thus pointing out the safe tools for amateurs to play with, without having to face the power tools so early on.  The pros can continue to come up with cool effects and layout tricks, but it sure would be nice to have a stable way to make a 2 or 3 column basic layout.  There are some good columns at A List Apart, which is a start, but there is still much variation, and always the caveats.  It's a start, but

There are a few code-generators out there, but I'm skeptical of them.  Perhaps that's hypocritical, but what I want is something in-between: demonstrations of basic techniques and simple CSS code that works, which I can combine, or add to (not modify, because then it might break).  I wish I could have my cake and eat it.  I want simpler, fewer choices, fewer pitfalls.  Am I asking for too much?

Ideally, a CSS-based layout should only need a few basic, semantic (X)HTML tags.  I don't mind adding semantic divs, but not empty ones or redundant wrapper divs.  A wrapper that contains more than one div might make sense, but that's as far as I'm willing to go.  I don't like layouts that require extra HTML tags for the CSS to play with.  That's leading back towards something analogous to nested tables and resulting tag-soup.  The Holy Grail remains to be able to do everything you need to each box independently, without the need for additional wrapper boxes for the non-standard buggy browsers that force you to restrict the CSS to a tiny subset of the specs.  I've sometimes considered using Javascript to add the DOM elements the CSS relies on, but that's dangerous because then the CSS relies on a piece of JavaScript, whose sole purpose is to support the style.  Not best practices, where content is separate from style and behaviour.

5 comments:

Anonymous said...

[b][url=http://www.louisvuittonpursessalenow.com/]www.louisvuittonpursessalenow.com[/url][/b] Challenges built-in toddler operate, small income, performing a number of hours and employee positive components. Activists contended that this kind of difficulties should not differ way very extensively from demands required under western culture, despite the fact that Nike asserted at the moment that different country broad financial and sociable predicaments dictated unique demands round the worldBono and Ali are donning Edun garments on your marketing and advertising campaign. Ali is observed obtaining an Edun/Lv collaboration bag.

[b][url=http://www.toplouisvuittonhandbags.co.uk/]louis vuitton uk[/url][/b] Staying bilingual or multilingual is a very major gain nowadays. You might have the ability to communicate with other people inside their very own language in addition to find out more regarding their lifestyle. Many educational institutions now include discovering of various languages inside their curriculum.

[b][url=http://www.louisvuittonwebsite.co.uk/]louis vuitton handbags[/url][/b] Due to this fact selected days the canine wouldn't consume, is that this as you adjusted their pretty own foodstuffs. A ruled the amount to work with is on top of that truly crucial benefit from transferring ahead closer to airless the labels. Discovering any slide not to point out get together has not been referring to consuming strategy, workout and likewise wellness,Celine Bags despite the fact that viewers nearly all ballet dancers having their incredibly private pastime truthfully tend to evade alcoholic consume if they are literally breaking a leg.
Even distance instruction happens to be much easier to deal with. With the current technological improvements in high-speed Online, length learning has become extra recognized for its possibilities to provide individualized notice and communication with college students throughout the globe. Built-in distance understanding (the integration of reside, in-group instruction or interaction having a distance-learning curriculum) is something which pursuits lots of individuals who would like to go on their training on line.

[b][url=http://www.uggukwebsite.co.uk/]uggs sale[/url][/b] Handbags built by Louis Vuitton are one of several most copied Luxury model from the world. They have got experienced worldwide fame with their higher finish designer purses. Louis Vuitton, the corporate is among one of the most trustworthy designer brand names, they usually have very strict tips on their patterns and top quality.

[b][url=http://www.louisvuittonwalletsmall.com/]louis vuitton purses[/url][/b] A peanut butter sandwich is pleasant, but, make that sandwich and slice it with petite cookie cutters into various princessly styles and you also have a little something magnificent. Even just cutting the sandwiches having a glass into a circle and then cutting the circles in fifty percent would perform. Display screen them nicely on the glass plate with a few red grapes or flowers and it no longer merely a unexciting sandwich but a delicacy that a delight to take a look at AND consume..

Anonymous said...

Hello. Facebook takes a [url=http://www.onlinecraps.gd]casinos online[/url] move on on 888 casino apportion: Facebook is expanding its efforts to present real-money gaming to millions of British users after announcing a prepare with the online gambling cast 888 Holdings.And Bye.

Anonymous said...

[url=http://saclongchampa.blinkweb.com/]sacs longchamp[/url] Do this- put piece B on your table with the right side facing up. Then, take your piece A and lay it right side DOWN on top of the piece B. Line Online Cheapest Mulberry Dan Nautral Leather Messenger Bag Brown for Men,Our Mulberry outlet store is one of the best Mulberry outlet online. up the top of piece B (the pleated part) with the longer side (in the picture of the pattern it is the "bottom" of piece A) of piece A.
[url=http://longchampsoldesa.yolasite.com/]sac longchamp moins cher[/url] Pelosi's antics but seemed to perk up when John Corzine shouted "boy" from across the auditorium. Corzine, who was also denied the coveted Golden Douchie, was Highly Appreciated Mulberry Women's Bayswater For 13 MacBook Light Coffee Bag, and we welcome for your coming and enjoy your online shopping at our Mulberry Bags store. Don't forget to choose one nice and cheap Mulberry bags. merely trying to get the attention of the black waiter on the other side of the room. He too was sooo drunk.
[url=http://www.nexopia.com/users/longchampplia/blog]longchamp soldes[/url] The Hermes handbags offered by us are well available in mesmerizing designs and disparate shapes in accordance to the needs of customers. Whether the hermes birkins bags were given or purchased directly, owning one-liner means elevating a certain to a higher frame status. The string bag's accommodate and vastness (standard assay is 35cm) is so classy that you can do Birkin any temporarily and the weave and the body of the Birkin Affordable Mulberry Women's Daria Leather Belt Black Bag supply cheap, Mulberry Handbags UK Online Shopping Outlet Store upright adds to its USP.. Both men and women carry bags, however, it is just well-known that women use them more than men. Furthermore, handbags are also use to create a fashion statement. Different designs and styles are born each year.. They are available in different sizes, shapes, colours and designs. Whatever be your taste, they are available in various designs, and would meet all your fashion requirements. You can look very fashionable and trendy with these different styles of wholesale purses.

Anonymous said...

You are absolutely right. In it something is and it is good thought. I support you.
I apologise, but, in my opinion, this theme is not so actual.
It is remarkable, rather valuable answer
It agree, the remarkable message
In it something is also to me this idea is pleasant, I completely with you agree.

[url=http://shenenmaoyif.xanga.com/771038318/advantages-of-choosing-oxo-biodegradable-plastic-bags/][b]michael kors outlet online[/b][/url]
[url=http://yaba.com/cheapmkbag2/blog/45279/][b]michael kors outlet online[/b][/url]
[url=http://www.shenenmaoyiw.350.com/][b]michael kors outlet online[/b][/url]
[url=http://shenenmaoyitt.devhub.com/][b]michael kors outlet online[/b][/url]
[url=http://cheapbags8.blogbaker.com/2013/01/17/exclusive-selection-of-bags-obtainable-in-louise-v][b]michael kors outlet online[/b][/url]

Unknown said...

Hi, The bind about is that majority of web designers avalanche abbreviate of these two important aspects. Worst, a lot of website developers do not accomplished these Web Design Cochin qualifications. I don't accept annihilation adjoin accomplished and active alone with ability on web architecture and development. Thanks....