Home >Web Front-end >HTML Tutorial >HTML object Tag
The HTML
The syntax for the HTML
<object data= "url " type= "content type "> . . . . . </object>
For instance,
<object height= "200" width= "400" data= "url"> </object>
It displays the object with the specified height and width attributes.
The parameters of the object tag are:
We can combine object elements, and using this possibility, we can define multiple objects for one browser each. While all major browsers do not support the object element, the use of the element is minimal.
Examples are as follows.
Code:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title> HTML Object Tag Example </title> <style> body { background-color: #8FBC8F; } </style> </head> <body> <center> <h2> HTML Object Tag</h2> <br> <object data= "https://www.shareasale.com/images/edu-logo.jpg" width="400px" height="200px"></object> </center> </body> </html>
Output:
Explanation: In the above example, we have created the object tag in the center of the web page with
Code:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title> HTML Object Tag Example </title> <style> body{ background-color: #8FBC8F; } </style> </head> <body> <center> <h2> HTML Object Tag</h2> <br> <object height="200px" width="400px" data="https://www.youtube.com/embed/Xs3MCM0dXW0"></object> </center> </body> </html>
Output:
Explanation: In the above example, we have embedded the video by using the HTML object tag with the help of height and width attributes which sets the video in the proper place. Embed the video url from YouTube and paste into the data attribute.
Code:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title> HTML Object Tag Example </title> <style> body{ background-color: #8FBC8F; } </style> </head> <body> <center> <h2> HTML Object Tag</h2> <br> <object data= "https://www.shareasale.com/images/edu-logo.jpg" width="400px" height="200px" vspace="150"></object> </center> </body> </html>
Output:
Explanation: In the above example, we have used the object tag to display the image on the web page. The object tag uses vspace attribute to define the whitespace on the top and bottom of an object element. Here, we are setting the margin on top and bottom with 150 pixels.
Code:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title> HTML Object Tag Example </title> <style> body{ background-color: #8FBC8F; } </style> </head> <body> <center> <h2> HTML Object Tag</h2> <br> <object data= "https://www.shareasale.com/images/edu-logo.jpg" width="400px" height="200px" border="8"></object> </center> </body> </html>
Output:
Explanation: In the above example, we have used the border attribute to display the border for the object element. The border attribute specifies the width of the border in the pixels. Here, we are representing the border width with 8 pixels.
So far, we have studied HTML object tags that can remain within Inline elements and block-level elements except for pre. In most instances, an HTML object inserts content assisted by browser plug-ins.
The above is the detailed content of HTML object Tag. For more information, please follow other related articles on the PHP Chinese website!