Search code examples
htmlobjectattributestagssrc

Why the object tag has the data attribute instead of src?


why, in the object tag, the attribute that is used to insert the external resource is called "data" instead of "src" as in all the other tags (audio, embed, iframe, img, input, script, source, track, video)?

For example:

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>

Thus, to enter into the web page a same external resource (for example, a video file), you have to use different attributes depending on the used tag (object or video). So, the possible reason (I do not doubt that there is one) for this difference is important enough to justify an exception to the principle of simplicity?

Thank you.

Juri


Solution

  • There's no specific reason, it was designed like that by the w3c.

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

    One of the big differences from the other tags is that, with the object tag, you can also declare your mime type of the data in the "type" attribute.