Recently, I took part in a thread at the International Web Developers Network that discussed the use of inline CSS to define the width and height of an image.
In short, you should not be using inline CSS (or external CSS) to define the height and width of an inline image.
Why? Because defining image dimensions is defining the structure of a Web page, and not defining the style. A style sheet should only define style.
Don’t worry, I was just as guilty as the next person of doing this. That was until I was shot down by a friend and with a quick explanation like I just gave, it became obvious it wasn’t the right thing to do.
With the big push in XHTML and CSS based layouts, where people are beginning to realise tables are for displaying tabular data, and not for defining the entire structure of a Web site, it’s becoming increasingly common to see people using CSS for things that CSS shouldn’t be used for. The example in this blog entry is just one.
Just because CSS is the new big thing (Umm. It’s not “new”, but it is the “new big thing”), it doesn’t mean it should be used for everything!