I just found out that I lost my wallet, so I need to let off steam. The following is some major nerdiness aimed at web design freaks, not the every day Joe who muddles about with HTML in his spare time. Cover your eyes, children.
I am getting sick and tired of stumbling over people who market themselves as good at CSS coding, even claiming to do semantic CSS, but still think it's okay to use inline styles.
Inline styles are not okay. In fact, inline styles are very, very bad.
Especially if anyone has to come after you and clean up your mess when you're nowhere near the project three years from now.
I suspect that the only people who think inline styles pass as a professional solution to a layout problem are most likely lacking in their design/CSS skills or experience, or more likely, have never had to update a site's appearance repeatedly over any length of time, say on the whims of a finicky client. Maybe they played with CSS in college or made some sites for some friends or a few clients who were tickled pink that everything looked just like the mockup, but I bet they never had to go back through that site and change every one of those inline tags into something they could actually edit in the future from the luxurious comfort of an external stylesheet.
Say there's an image on a couple of pages, and you want to center it. You use a style = "text-align:center" in the image tag, and baddaboom, you have a centered image. You think this is fine. You feel rather smart that, hey hey, you're using CSS now! Not really.
You're using the right code, but you're using it like the old font and center tags of yore, the very tags that CSS was created to abolish.
If you're using inline styles like deprecated tags, you might as well go ahead and use the deprecated tags.
But Rachel, you may ask, are there not legitimate instances where an inline style has a place? Like what if it's just one picture on just one page?
If you could assure me that that was the only picture on the only page, I might let it go. But you know what? You're probably going to use another picture on another page and want the same effect. So you use the inline style again. And again. And again.
Then, three years later, you or I come along and say, hmm, the centered image isn't really working. Let me make it left-aligned. Better yet, I'll float it so the text runs around it!
But I can't. Because all of those seemingly harmless little inline styles are standing in my way. Instead of using a class and defining that as centered in your style sheet, instead of giving me, you, and any other person the ability to change all those images from one spot, I have to rummage through the whole damn site to fix it up.
And because it's inline, it over rules stylesheets in the cascade. I have to use Dreamweaver's find and replace tools to tear through all that code when I could have just changed a few things on a stylesheet. That is not how CSS was meant to be used.
I'm sure somewhere out there is a legitimate reason to use inline styles. I just haven't encountered it yet.
I was once a CSS jockey who thought inline styles were cool, especially if they were in a template system. Then I went to work at a little web development company where my lord and master was a CSS Nazi. Seriously, if he caught me using inline styles, I was tied to a rack and flayed alive. I was terrified to use the things! What's the big deal? I thought. It's just one tiny change!
And then one day a client requested a change on a very ornately structured home page. I took one look and nearly peed myself. I knew I would break something. I knew that it was going to need hours of redesign. Then I look at the thing they wanted changed. Then I looked at the stylesheet.
That's when I understood why my superior was so anti-inline styles.
The change was simple to make. It was painless and fit perfectly with the rest of the site. It was only then that I realized what he meant about separating display from content. I knew CSS, but it was like knowing how a car worked. This moment in my life was akin to finally figuring out how to change gears. I found I could move forward. With fickle clients, I was always having to change minute details. With CSS, it was less like pulling nails and more like having a manicure.
After that I unquestioningly followed his advice. Everything was id-ed or classed according to its role in the greater scheme of the site, not by its color or position or mere alphanumerical fancy.
Once upon a time, I had mocked him for getting bent out of shape about inline styles and poor naming conventions. And then one day, I found myself leaning over someone else's shoulder, patiently trying to explain to them the same concepts he had patiently tried explaining to me.
I had become another CSS Nazi.
Nazi is actually a little strong actually. Perhaps CSS Reaver is closer to the mark. It was through suffering that I learned the tenacious organizational madness of a true CSS coder. And when I turned, I began to inflict my insanity on all those around me. I cannot bear the site of bad CSS. I get the urge to start ripping out code, festooning my desktop with its remains and capering at its demise.
For me, there is no going back.
A final word: I have found in cases when working with severely poorly coded/old/crippled sites, sometimes using an inline style is just faster than redoing the entire site's code to conform with your own standards of perfection. But if you're building a site from the ground up, the only excuse to not properly use CSS is ignorance. And if you don't do CSS for a living, I understand, and it's okay. Not everyone should have to spend two months studying so they can get one aspect of a personal site up to the standards of web snobbery. But if you get paid to code in CSS, that's just shoddy craftsmanship, and you really do need to read a book. Like one of these! (In this order!)
Bulletproof Web Design by Dan Cederholm
Web Standards Solutions also by Dan Cederholm
CSS Mastery by Andy Budd, Simon Collison and Cameron Moll
I had to get that out of my system. Thank you for listening.