On the names of CSS background images

Semantics is a good thing on the web, but it can actually turn out to be harmful if not used properly. A common approach in writing names of CSS background images is to map image names to element names. For example, if you have an element with an ID named branding, the corresponding image name should be branding.jpg and so on. So far so good, because IDs are something unique throughout an entire web page. But what happens with other elements, for example class names? As a rule of thumb, you should always choose image names that can be reused or you will end up with the same image having dozens of different names. For example, if you have an image named link.gif, you can use that either on a breadcrumb trail or on external links, instead of renaming it breadcrumbs.gif and external.gif, respectively. In a nutshell: use semantics properly and with a little bit of common sense, or you'll probably bang your head on the desk while trying to remember the name of your CSS background images.

This entry was posted in by Gabriele Romanato. Bookmark the permalink.

Leave a Reply

Note: Only a member of this blog may post a comment.