HTML DOM Source src Property Last Updated : 22 Jun, 2023 Comments Improve Suggest changes Like Article Like Report The Source src Property in HTML DOM is used to set or return the value of the src attribute in a <source> element. The src attribute is used to specify the URL of the media resource. Syntax: It returns the Source src property. sourceObject.srcIt is used to set the Source src property.sourceObject.src = URL Property Values: It contains a single value URL that specifies the URL of the media resource. It can be either an absolute or a relative URL. Two Possible Values: Absolute URL: It points to another webpage.Relative URL: It points to other files of the same web page. Return Value: It returns a string value that represents the URL of the media resource. Example 1: This example returns the Source src Property. HTML <!DOCTYPE html> <html> <head> <style> body { text-align: center; } h1 { color: green; } </style> </head> <body> <h1>GeeksforGeeks</h1> <h2>HTML DOM Source src property</h2> <audio controls> <source id="mySource" src="gameover.wav" type="audio/mpeg"> <source src="gameover.ogg" type="audio/ogg"> </audio> <p> Click the button to get the source/src of the audio file. </p> <button onclick="myFunction()"> Get Src </button> <p id="demo"></p> <script> function myFunction() { let x = document.getElementById("mySource").src; document.getElementById("demo").innerHTML = x; } </script> </body> </html> Output: Example 2: This example sets the Source src property. HTML <!DOCTYPE html> <html> <head> <style> body { text-align: center; } h1 { color: green; } </style> </head> <body> <h1>GeeksforGeeks</h1> <h2>HTML DOM Source src property</h2> <audio controls> <source id="mySource" src="gameover1.wav" type="audio/mpeg"> <source src="gameover.ogg" type="audio/ogg"> </audio> <p> Click the button to set the source src of the audio file. </p> <button onclick="myFunction()"> Set Src </button> <p id="demo"></p> <script> function myFunction() { let x = document.getElementById("mySource").type = "gameover.wav"; document.getElementById("demo").innerHTML = "The source src has been changed to " + x; } </script> </body> </html> Output: Supported Browsers: Google ChromeFirefoxInternet ExplorerOperaSafari Comment More infoAdvertise with us Next Article HTML DOM Source src Property M manaschhabra2 Follow Improve Article Tags : Web Technologies HTML HTML-DOM Similar Reads HTML DOM Source type Property The Source type Property in HTML DOM is used to set or return the value of the type attribute in a <source> element. The type attribute is used to specify the MIME type of the media resource. Syntax: It returns the Source type property. sourceObject.typeIt is used to set the Source type proper 2 min read HTML | DOM Track src property The DOM track src property is used to set or return the value of the src attribute which shows the URL of the text track. Syntax: It is used to return the Track src property. trackObject.src It is also used to set the Track src property. trackObject.src = URL Value: URL: It is used to specify the UR 1 min read HTML DOM Script src Property The DOM Script src Property is used to set or return the value of the src attribute of an <script> element. The src attribute specifies the URL of the External Javascript file. Syntax: It returns the src property:scriptObject.srcIt is used to set the src property:scriptObject.src = URL Propert 1 min read HTML DOM Source media Property The HTML DOM Source media Property is used to set or return the value of the media attribute of the <source> element. The <source> media attribute is used to accept any valid media query that would normally be defined in a CSS. This attribute can accept several values. Syntax: It is used 2 min read HTML DOM URL Property The DOM URL property in HTML is used to return a string that contains the complete URL of the current document. The string also includes the HTTP protocol such as ( http://).Syntax:document.URLReturn Value: It returns a string value that represents the full URL of the document. Example: In this exam 2 min read HTML | DOM Track srclang property The DOM track srclang property is used to set or return the value of the srclang attribute which shows the language of the text track. Note: srclang attribute is required with kind = "subtitles" Syntax: It is used to return the Track srclang property. trackObject.srclang It is also used to set the T 1 min read HTML | DOM Video src Property The Video src property is used for setting or returning the value of the src attribute of a video. The src attribute is generally used to specify the location (URL) of the video file. Syntax: Return the src property:videoObject.srcSet the src property:videoObject.src = URL Property Values: URL: It i 2 min read HTML DOM value Property The DOM value property in HTML is used to set or return the value of any attribute.Syntax: It returns the attribute value. attribute.valueIt is used to set a value to the property. attribute.value = valueProperty Value: value: It defines the value of the attribute.Return Value: It returns a string v 2 min read HTML | DOM Source Object 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 2 min read Like