【问题标题】:Why the object tag has the data attribute instead of src?为什么object标签有data属性而不是src?
【发布时间】:2016-09-23 15:02:09
【问题描述】:

为什么在 object 标记中,用于插入外部资源的属性称为“data”而不是所有其他标记(audio、embed、iframe、img、input、script、source)中的“src” ,轨道,视频)?

例如:

Object tag: <object data="https://www.w3.org/html/logo/downloads/HTML5_Logo_512.png" width=50 height=50>
</object>

All other tags: <img src="https://www.w3.org/html/logo/downloads/HTML5_Logo_512.png" width=50 height=50>

因此,要在网页中输入相同的外部资源(例如,视频文件),您必须根据使用的标签(对象或视频)使用不同的属性。那么,造成这种差异的可能原因(我不怀疑有一个原因)是否重要到足以证明对简单性原则的例外?

谢谢。

朱里

【问题讨论】:

标签: html object attributes tags src


【解决方案1】:

没有具体原因,w3c就是这样设计的。

https://developer.mozilla.org/en-US/docs/Web/HTML/Element/object

与其他标签的一大区别是,使用object标签,您还可以在“type”属性中声明数据的mime类型。

【讨论】:

    猜你喜欢
    • 2016-05-12
    • 2013-02-25
    • 2013-08-16
    • 2023-03-31
    • 1970-01-01
    • 2011-01-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多