This page is Almost Ready

Notice: The WebPlatform project, supported by various stewards between 2012 and 2015, has been discontinued. This site is now available on github.

createElementNS

Summary

Creates an element from the specified namespace as a stand-alone object (unattached to the DOM).

Method of dom/Documentdom/Document

Syntax

var element = document.createElementNS(namespace, tagName);

Parameters

namespace

Data-type
String

The URI of the desired namespace. This is the actual URI value, not the prefix used in the mark-up.

tagName

Data-type
String

The name of the desired element.

Return Value

Returns an object of type DOM NodeDOM Node

The created element.

Examples

The following code example creates a circle element from the SVG namespace.

var sNamespace = "http://www.w3.org/2000/svg";
var oCircle = document.createElementNS(sNamespace, "circle");

Notes

The createElementNS method is supported only for XML namespaces.

Related specifications

DOM Level 3 Core
Recommendation

Attributions