Open In App

How to specify media type of data specified in data attribute in HTML5 ?

The following approach covers how to specify the URL of the resource to be used by the object in HTML5. This can be used in pages where content from an external source is required.

Approach: We will use the data attribute of the <object> element to specify the URL of the resource that to be used for the object. The specified URL can be relative or absolute.



Syntax:

<object data="URL">

The below example illustrates the data attribute to specify the URL of the resource to be used by the object.



Example:




<!DOCTYPE html>
<html>
  
<body>
    <h1 style="color: green;">
        GeeksforGeeks
    </h1>
  
    <p>Object with an image resource:</p>
  
    <object data=
    </object>
  
    <p>Object with a video resource:</p>
  
    <object data=
    </object>
</body>
  
</html>

Output:

Article Tags :