
- HTML Tutorial
- HTML - Home
- HTML - Overview
- HTML - Basic Tags
- HTML - Elements
- HTML - Attributes
- HTML - Formatting
- HTML - Phrase Tags
- HTML - Meta Tags
- HTML - Comments
- HTML - Images
- HTML - Tables
- HTML - Lists
- HTML - Text Links
- HTML - Image Links
- HTML - Email Links
- HTML - Frames
- HTML - Iframes
- HTML - Blocks
- HTML - Backgrounds
- HTML - Colors
- HTML - Fonts
- HTML - Forms
- HTML - Embed Multimedia
- HTML - Marquees
- HTML - Header
- HTML - Style Sheet
- HTML - Javascript
- HTML - Layouts
- HTML References
- HTML - Tags Reference
- HTML - Attributes Reference
- HTML - Events Reference
- HTML - Fonts Reference
- HTML - ASCII Codes
- ASCII Table Lookup
- HTML - Color Names
- HTML - Entities
- HTML - Fonts Ref
- HTML - Events Ref
- MIME Media Types
- HTML - URL Encoding
- Language ISO Codes
- HTML - Character Encodings
- HTML - Deprecated Tags
HTML DOM name Property
The HTML DOM name property returns a string corresponding to the name of the attribute of an element.
Following is the syntax −
Returning string value
elementAttribute.name
Let us see an example of HTML DOM name property −
<!DOCTYPE html> <html> <head> <title>HTML DOM name</title> <style> * { padding: 2px; margin:5px; } form { width:70%; margin: 0 auto; text-align: center; } input[type="button"] { border-radius: 10px; } </style> </head> <body> <form> <fieldset> <legend>HTML-DOM-name</legend> <img src="https://www.tutorialspoint.com/data_communication_computer_network/images/dcn- mini-logo.jpg"> <div id="divDisplay">What attribute in img element is used as a source path?</div> <input type="button" value="Get Answer" onclick="getAnswers()"> </fieldset> </form> <script> var divDisplay = document.getElementById("divDisplay"); function getAnswers() { var ans = document.getElementsByTagName('img')[0].attributes[0].name; divDisplay.textContent = 'A \"'+ans+'\" attribute is used as a source path in img element'; } </script> </body> </html>
Output
Before clicking ‘Get Answer’ button −
After clicking ‘Get Answer’ button −
- Related Articles
- HTML DOM Object name Property
- HTML DOM Button name Property
- HTML DOM Textarea name Property
- HTML DOM Form name Property
- HTML DOM Fieldset name property
- HTML DOM Select name Property
- HTML DOM Input URL name Property
- HTML DOM Input Week name Property
- HTML DOM Input Password name Property
- HTML DOM Input Reset name property
- HTML DOM Input Search name Property
- HTML DOM Input Submit name property
- HTML DOM Input Text name Property
- HTML DOM Input Radio name Property
- HTML DOM Input Range name property

Advertisements