使用精灵与IMG标签? [英] Using sprites with IMG tag?

查看:172
本文介绍了使用精灵与IMG标签?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道如何使用精灵,但是,不是一个src属性所需的IMG标签?我可以总是使用SPAN或其他标签,并设置背景/宽度/等,但它不会语义正确。

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.

基本上,我想省略一个IMG标签的SRC,只使用精灵,但我担心HTML在技术上是无效的,因为它。感谢。

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.

推荐答案

关于语义正确性:

图像具有语义意义,因此它被认为是内容,使用IMG标记,没有精灵,并且正确设置了ALT。

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.

当图片只是装饰时,像框的背景,按钮的背景,菜单选项的背景等,它没有语义意义,所以你可以将其用作CSS的SPAN,DIV等的背景。在这种情况下,您可以使用sprite。

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.

这篇关于使用精灵与IMG标签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆