Using sprites with IMG tag?

I understand how to use sprites, however, isn't a "src" attribute required for IMG tags? I could always use a SPAN or other tag and set the background/width/etc but it won't be semantically correct.

Basically, I'd like to omit the SRC for an IMG tag and use just sprites, but am concerned about the HTML not being technically valid because of it. Thanks.


About semantical correctness:

When an image has semantical meaning, so it is considered to be content, use an IMG tag, without sprites, and a correctly set up ALT.

When an image is just decoration, like the background of a box, background of a button, background of a menu option, etc., it has no semantical meaning, so you can just use it as a background of a SPAN, DIV, etc. from CSS. You can use sprites in this case.

Using sprites doesn't necessarily mean you need to define them in css backgrounds. You can also use IMG tag sprites, to do so you need basically trim your image. There are two good articles explaining that technique:

Both CSS and IMG methods sure have their own benefits, so you need to figure out which one suits you better.

Need Your Help

Access Violation runtime error when getting WebBrowser .Url property

c# outlook add-in

Getting an "Access Violation" runtime error when trying to get a WebBrowser's .Url property in an Outlook Add-In I'm writing. Need some help on how to get past this please. Research indicates I may...

How to get both div to be the same height

html css

I have a website where I need the main page and the right panel div elements to be the same height.