HTML | DOM Object Object Last Updated : 11 Jul, 2025 Comments Improve Suggest changes 2 Likes Like Report The Object object represents only HTML <object> element. We can access any <object> element by using the getElementById(); and also can create object element by using createElement(); method.Syntax: It is used to access Object element document.getElementById("id"); It is used to create object element document.createElement("object"); Property Values: PropertyDescriptionalignIt is used to set or return the alignment of the objectarchiveIt is used to set or return a string which is useful in implementation of archive functionborderIt is used to set or returnsthe border around objectcodeIt is used to set or return the src url of files of compiled java classes.codeBaseIt is used to set or return URL of componentsdataIt is used to set or return the URL of the resourceformIt is used to return parent form's referenceheightIt is used to set or return object's heighthspaceSet or return horizontal marginnameSet or return object's namestandbyIt is used to sets or return message while object loadingtypeIt is used to sets or return the content type for data downloadeduseMapIt is used to sets or returns the name of a image map of client-sidevspaceSets or return vertical marginwidthIt is used to sets or return width of object Example-1: Access object element and return the URL of the resource html <!DOCTYPE html> <html> <body> <center> <object id="myobject" width="400" data="https://media.geeksforgeeks.org/wp-content/uploads/geek-8.png"> </object> <p>Click the button to get the URL of the embedded file.</p> <button onclick="Geeks()"> Click it </button> <p id="gfg"></p> </center> <script> function Geeks() { // Accessing Object element. var x = document.getElementById( "myobject").data; document.getElementById( "gfg").innerHTML = x; } </script> </body> </html> Output: Before clicking on the button: After clicking on the button: Example-2: Create object element using document.createElement. html <!DOCTYPE html> <html> <body> <center> <p>Click the button to create an Object element with an embedded file.</p> <button onclick="Geeks()"> Click it </button> <p id="gfg"></p> <script> function Geeks() { // Creating object element. var x = document.createElement( "OBJECT"); // Set data of the OBJECT. x.setAttribute("data", "https://media.geeksforgeeks.org/wp-content/uploads/geek-8.png"); x.setAttribute("width", "400"); x.setAttribute("height", "100"); document.body.appendChild(x); } </script> </center> </body> </html> Output: Before clicking on the button: After clicking on the button: Supported Browsers: Google ChromeMozilla FirefoxEdgeSafariOpera Create Quiz Comment S Sabya_Samadder Follow 2 Improve S Sabya_Samadder Follow 2 Improve Article Tags : Web Technologies HTML HTML-DOM Explore HTML BasicsHTML Introduction4 min readHTML Editors4 min readHTML Basics7 min readStructure & ElementsHTML Elements4 min readHTML Attributes7 min readHTML Headings3 min readHTML Paragraphs3 min readHTML Text Formatting4 min readHTML Block and Inline Elements3 min readHTML Charsets4 min readListsHTML Lists3 min readHTML Ordered Lists5 min readHTML Unordered Lists4 min readHTML Description Lists3 min readVisuals & MediaHTML Colors11 min readHTML Links Hyperlinks2 min readHTML Images7 min readHTML Favicon4 min readHTML Video4 min readLayouts & DesignsHTML Tables9 min readHTML Iframes4 min readHTML Layout4 min readHTML File Paths3 min readProjects & Advanced TopicsHTML Forms4 min readHTML5 Semantics5 min readHTML URL Encoding4 min readHTML Responsive Web Design11 min readTop 10 Projects For Beginners To Practice HTML and CSS Skills8 min readTutorial ReferencesHTML Tags - A to Z List5 min readHTML Attributes Complete Reference8 min readHTML Global Attributes5 min readHTML5 Complete Reference8 min readHTML5 MathML Complete Reference3 min readHTML DOM Complete Reference15+ min readHTML DOM Audio/Video Complete Reference2 min readSVG Element Complete Reference5 min readSVG Attribute Complete Reference8 min readSVG Property Complete Reference7 min readHTML Canvas Complete Reference4 min read Like