html - Is it always more semantically correct to use <img> rather than <div> or <span> to do CSS sprite? -


i used css sprite <div>, better <img> , apply css either display: block or display: inline-block more semantically correct? (because image).

no.

  • if image part of content, specify in html.
    img, object, ….
  • if image part of design, specify in css.
    content, background-image, …

it is possible specify design (decorative) images in html (using empty alt attribute), not recommended:

purely decorative images visual enhancements, decorations or embellishments provide no function or information beyond aesthetics users can view images.

[…]

while not unacceptable include decorative images inline, recommended if purely decorative include image using css.

however, i’d specifying sprites (containing different images) in html elegant. what alternative content? example: sprite containing portrait of person , site logo. might work users specify alternative content of image part shown (controlled css), fail users image without css support. see whole image file, wouldn’t make sense in context.


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -