The art of CSS…and the deception of padding
One of the most enjoyable tasks that a web developer can undertake is to “tweak” the CSS for a certain web site. The effort/pay out ratio is so far skewed for the developer — instant gratification definitely accurately describes the situation. Type in a few lines of code here and there…and you’ll have a whole new feel for not just one page, but the entire site.
I’ve been meaning to write a lot more about code here in this blog, and with CSS being my bread and butter, there isn’t a better place to start.
The first item on my mind is something they tried to drill into my head at Elizabethtown College, and that is the idea of “well-formed code.” Back in those days, I did truly resent the ideas my professors had to pass onto me, and the idea of taking something that can be creative (like code) and forcing it into some sort of conformist shape…well, i hated it. After all, if I could easily read the code, what did I care if someone else couldn’t? Well, well, well. In my line of work now, this concept of well-formed code is something I now cherish, yet so rarely see. It makes a huge difference to a new developer to code formed in such a way that you can actually…read it? I’ve found that my first task when I take control of a new web site is to structurally reform ALL of the code…but most importantly, to reform the CSS. If I can’t read it quickly, then I can’t work with it. Let that be a lesson to all coders — take the extra time, and the karmal debt of forming proper code should be repaid some day.
Also, I’ve concluded that in one of the future releases of CSS that the idea of padding should be eliminated. Lol, I know this is brash, non-sensical to some extent, and without true backing…but padding can be considered the root of all CSS evil. Case in point: while working on a recent project, I decided to retry certain styling methods that involved padding. I had given up on it sometime ago…but said, “Ah, what the heck. I know much more now, I’m sure it’ll be fine.” And honestly, my usage of the padding attribute was pretty much by the text. Rather pleased with myself, I decided to just do a little bit of research, and tested the site that was perfect in IE7 and FF in IE6. It was seriously as though someone had picked up my entire site, and just dropped it straight down, landing flat on a hard surface. The next 45 minutes was spent going between browsers, back and forth finding which ways to fix my pixel perfect design…and then success. And what did I discover? I had eliminated all instances of padding from my CSS file. All of them…the design was flawless, and the code was actually 7 lines shorter. For me, that’s more than enough to say: DOWN WITH PADDING!


