New Perspectives On Web Design

(C. Jardin) #1
By Christian Heilmann CHAPTER 3

Things I’ve never seen, I cannot miss. Things I can see that don’t work,
frustrate me. A lack of support is a great opportunity to not promise things
you cannot and should not try to offer.


bRowSeR-SPeCifiC CoDe CannoT be TRuSTeD


Each line of code you write with browser prefixes simply adds to the mass of code
that will break very, very soon.
The release of the iPhone and the subsequent stir in the developer
community made the hair on the back of my neck prickle. I was vividly re-
minded of the times when people told me that everything that only works
in IE6 and no other browser is what every developer should follow, as there
will be no other browsers in the future. That turned out to be rubbish, and
so is all the code on the Web now that only works on the first generation
iPhone, or even blocks other browsers from accessing the content of the
page at all.
If you ever encounter a white button with white text there is a distinct
possibility that the developer used -webkit-linear-gradient and noth-
ing else on the button’s CSS background definition. This is neither clever,
modern nor pragmatic. It is broken code that only worked for a very short
time in a fleeting environment. Writing browser-specific code is much like
releasing movies only on VHS. It seems like a cheap and quick solution at
the time and gets the job done, but it leaves you with thousands of unsold
copies that nobody can watch because the hardware is obsolete.
If you use prefixed code, at least wrap it in a test condition. The best
way, however, is to precede it with a fallback that works everywhere and
follow that with the standardized code. In the example of the button with
white text on a white background, all would be fine if the developer de-
fined a background first and a browser-specific linear gradient afterwards.
Browser-specific code is a to-do. If you cannot revisit and fix the code
once the functionality has been standardized then you write broken, unre-
liable code. Environments change. That is why we have standards.

Free download pdf