src和data-src属性之间有什么区别? [英] What are all the differences between src and data-src attributes?

查看:956
本文介绍了src和data-src属性之间有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用 data-src src 属性的差异和后果(无论是好还是坏) img 标记?我可以使用两者达到相同的结果吗?如果是这样,什么时候应该使用它们中的每一个? 属性 src data-src 没有任何共同之处,除了它们都被HTML5 CR所允许并且它们都包含字母 src 。其他的都不一样。

src 属性在HTML规范中定义,它有一个功能含义。 / p>

data-src 属性只是数据的无限集合之一 - * 属性,它们没有定义的含义,但可用于在元素中包含不可见的数据,以用于脚本(或样式)。


What are differences and consequences (both good and bad) of using either data-src or src attribute of img tag? Can I achieve the same results using both? If so, when should be used each of them?

解决方案

The attributes src and data-src have nothing in common, except that they are both allowed by HTML5 CR and they both contain the letters src. Everything else is different.

The src attribute is defined in HTML specs, and it has a functional meaning.

The data-src attribute is just one of the infinite set of data-* attributes, which have no defined meaning but can be used to include invisible data in an element, for use in scripting (or styling).

这篇关于src和data-src属性之间有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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