HTML | DOM Source Object Last Updated : 14 Jan, 2022 Comments Improve Suggest changes Like Article Like Report The Source object in HTML represents an HTML element. An element can be accessed by using getElementById() and an element can be created by using the document.createElement() method. Properties of Source Object: media: This returns the value of the media attribute in a element. src: This returns the value of the src attribute in a element. type: This returns the value of the type attribute in a element. Example-1: Accessing a Source Object html <!DOCTYPE html> <html> <head> <style> body { text-align: center; } h1 { color: green; } </style> </head> <body> <h1>GeeksforGeeks</h1> <h2>HTML DOM Source Object</h2> <h3>An example of accessing a source element</h3> <audio controls> <source id="mySource" src="gameover.wav" type="audio/mpeg"> <source src="gameover.ogg" type="audio/ogg"> Your browser does not support the audio element. </audio> <p>Click the button to get the location of the audio file.</p> <button onclick="myFunction()"> Get Source </button> <p id="demo"></p> <script> function myFunction() { var x = document.getElementById( "mySource").src; document.getElementById( "demo").innerHTML = x; } </script> </body> </html> Output: Example-2: Creating a Source Object. html <!DOCTYPE html> <html> <head> <style> body { text-align: center; } h1 { color: green; } </style> <head> <body> <h1>GeeksforGeeks</h1> <h2>HTML DOM Source Object</h2> <h3>An example of creating a source element </h3> <p>Click the button to create the source element. </p> <audio controls id="myAudio" autoplay> Your browser does not support the audio element. </audio> <br> <p id="demo"></p> <button onclick="myFunction()"> Create </button> <script> function myFunction() { var x = document.createElement("SOURCE"); x.setAttribute("src", "gameover.wav"); x.setAttribute("type", "audio/mpeg"); document.getElementById( "myAudio").appendChild(x); var y = document.createElement("SOURCE"); y.setAttribute("src", "gameover.ogg"); y.setAttribute("type", "audio/ogg"); document.getElementById("myAudio").appendChild(y); document.getElementById("demo").innerHTML = "The audio player now works."; } </script> </body> </html> Output: Supported Browsers: Google Chrome Mozilla Firefox Edge Safari Opera Comment More infoAdvertise with us Next Article HTML | DOM Source Object apeksharustagi1998 Follow Improve Article Tags : Web Technologies HTML HTML-DOM Similar Reads HTML | DOM Pre Object The DOM Pre Object is used to represent the HTML <pre> element. The pre element is accessed by getElementById().Properties: width: It is used to set or return the value of the width attribute of the pre element. Syntax: document.getElementById("ID"); Where âidâ is the ID assigned to the âpreâ 1 min read HTML DOM S Object The S Object in HTML DOM is used to represent the HTML <s> element. This tag is used to specify that the text content is no longer correct or accurate. The <s> element can be accessed by using the getElementById() method. Syntax: document.getElementById("id"); Where id is assigned to the 1 min read HTML | DOM Ol Object The DOM Ol Object is used to represent the HTML <ol> element . The ol element is accessed by getElementById(). To read more about lists check HTML | Lists. Properties: compact: It is used to set or return whether the size of the list would be displayed normal or not.reversed: It is used to set 2 min read HTML | DOM Track Object The Track object in HTML represents an HTML <track> element.Accessing a Track Object: A Track Object can be accessed by using getElementById() method. This method is used to returns the element that has the ID attribute. var x = document.getElementById("Track"); Creating a Track Object: A Trac 2 min read HTML | DOM Quote Object The Quote Object in HTML DOM is used to represent the HTML <q> element. The quote element can be accessed by using getElementById() method.Property Value: It contains single attribute value cite. This attribute is used to set or return the value of the cite attribute in a <q> element.Syn 2 min read HTML | DOM Summary Object The DOM Summary Object is used to represent the HTML <summary> element . The Summary element is accessed by getElementById(). Syntax: document.getElementById("ID"); Where âidâ is the ID assigned to the âsummaryâ tag. Example-1: html <!DOCTYPE html> <html> <head> <title> 2 min read HTML | DOM Object Object 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 o 2 min read HTML | DOM Script Object The DOM Script Object is used to represent the HTML <script> element. The script element is accessed by getElementById(). Properties: async: It is used to specify the script is executed asynchronously. charset: It is used to specify the character encoding used in an external script file. defer 2 min read HTML DOM Superscript Object The superscript object in HTML DOM is used to represent the HTML <sup> element. The superscript element can be accessed by using getElementById(). Syntax: document.getElementById("id") Where id is assigned to the <sup> tag. Example: In this example, we will use DOM Superscript Object HTM 1 min read HTML DOM Output Object The HTML DOM Output Object is used to represent the HTML <Output> Tag . The output element is accessed by getElementById(). Syntax: document.getElementById("id"); Where âidâ is the ID assigned to the âoutput â tag. Values: default Value: It is used to set or return the default value of the 2 min read Like