Open In App

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

Last Updated : 31 Mar, 2021
Improve
Improve
Like Article
Like
Save
Share
Report

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:

HTML




<!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:


Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads