
- HTML Home
- HTML Roadmap
- HTML Introduction
- HTML History & Evolution
- HTML Editors
- HTML Basic Tags
- HTML Elements
- HTML Attributes
- HTML Headings
- HTML Paragraphs
- HTML Fonts
- HTML Blocks
- HTML Style Sheet
- HTML Formatting
- HTML Quotations
- HTML - Comments
- HTML - Colors
- HTML - Images
- HTML - Image Map
- HTML - Frames
- HTML - Iframes
- HTML - Phrase Elements
- HTML - Code Elements
- HTML - Meta Tags
- HTML - Classes
- HTML - IDs
- HTML - Backgrounds
- HTML Tables
- HTML - Tables
- HTML - Table Headers & Captions
- HTML - Table Styling
- HTML - Table Colgroup
- HTML - Nested Tables
- HTML Lists
- HTML - Lists
- HTML - Unordered Lists
- HTML - Ordered Lists
- HTML - Definition Lists
- HTML Links
- HTML - Text Links
- HTML - Image Links
- HTML - Email Links
- HTML Color Names & Values
- HTML - Color Names
- HTML - RGB & RGBA Colors
- HTML - HEX Colors
- HTML - HSL & HSLA Colors
- HTML - HSL Color Picker
- HTML Forms
- HTML - Forms
- HTML - Form Attributes
- HTML - Form Control
- HTML - Input Attributes
- HTML Media
- HTML - Video Element
- HTML - Audio Element
- HTML - Embed Multimedia
- HTML Header
- HTML - Head Element
- HTML - Adding Favicon
- HTML - Javascript
- HTML Layouts
- HTML - Layouts
- HTML - Layout Elements
- HTML - Layout using CSS
- HTML - Responsiveness
- HTML - Symbols
- HTML - Emojis
- HTML - Style Guide
- HTML Graphics
- HTML - SVG
- HTML - Canvas
- HTML APIs
- HTML - Geolocation API
- HTML - Drag & Drop API
- HTML - Web Workers API
- HTML - WebSocket
- HTML - Web Storage
- HTML - Server Sent Events
- HTML Miscellaneous
- HTML - Document Object Model (DOM)
- HTML - MathML
- HTML - Microdata
- HTML - IndexedDB
- HTML - Web Messaging
- HTML - Web CORS
- HTML - Web RTC
- HTML Demo
- HTML - Audio Player
- HTML - Video Player
- HTML - Web slide Desk
- HTML Tools
- HTML - Velocity Draw
- HTML - QR Code
- HTML - Modernizer
- HTML - Validation
- HTML - Color Picker
- HTML References
- HTML - Cheat Sheet
- HTML - Tags Reference
- HTML - Attributes Reference
- HTML - Events Reference
- HTML - Fonts Reference
- HTML - ASCII Codes
- ASCII Table Lookup
- HTML - Color Names
- HTML - Character Entities
- MIME Media Types
- HTML - URL Encoding
- Language ISO Codes
- HTML - Character Encodings
- HTML - Deprecated Tags
- HTML Resources
- HTML - Quick Guide
- HTML - Useful Resources
- HTML - Color Code Builder
- HTML - Online Editor
HTML - DOM Element namespaceURI Property
The HTML DOM Element namespaceURI property is used to retrieve the namespace URI of an element in the document. It returns "null" if the given element is not a part of the namespace.
A namespace URI in HTML is a Uniform Resource Identifier (URI) used to define the namespace for elements and attributes in an XML or XHTML document.
Syntax
Following is the syntax of the HTML DOM Element namespaceURI property −
element.namespaceURI
Parameters
Since this is a property, it will not accept any parameter.
Return Value
This property returns a string that contains the URI of the element's namespace or null if the element is not part of any namespace.
Example 1: Getting namespace URI of Element
The following is the basic example of the HTML DOM Element namespaceURI. It retrieves the namespace URI of an element in the document −
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>HTML DOM Element namespaceURI</title> </head> <body> <h3>HTML DOM Element namespaceURI Property</h3> <div id="myDiv">Hello, World!</div> <div id="result"></div> <script> const divElement = document.getElementById('myDiv'); const namespaceURI = divElement.namespaceURI; // Display the namespace URI in the result element const resultElement = document.getElementById('result'); resultElement.textContent = `Namespace URI of #myDiv: ${namespaceURI}`; </script> </body> </html>
The above program displays the namespace URI of the "div" element.
Example 2: Getting namspace URI of Element in XHTML
Here is another example of the HTML DOM Element namespaceURI property. We use this property to retrieve the namespace URI of an SVG element −
<!DOCTYPE html> <html> <head> <title>HTML DOM Element namespaceURI</title> </head> <body> <h3>HTML DOM Element namespaceURI Property</h3> <svg xmlns="http://www.w3.org/2000/svg" width="100" height="100"> <circle id="myCircle" cx="50" cy="50" r="40" stroke="black" stroke-width="2" fill="red" /> </svg> <p id="result"></p> <script> const circleElement = document.getElementById('myCircle'); const namespaceURI = circleElement.namespaceURI; const resultElement = document.getElementById('result'); // Updates the HTML content resultElement.textContent = `Namespace URI of #myCircle: ${namespaceURI}`; </script> </body> </html>
Once the above program is executed, it displays the name-space URI of the SVG element.
Supported Browsers
Property | ![]() |
![]() |
![]() |
![]() |
![]() |
---|---|---|---|---|---|
namespaceURI | Yes | Yes | Yes | Yes | Yes |