This page is In Progress

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

setAttributeNS

Summary

Sets the value of a content attribute in a specified namespace.

Method of dom/Elementdom/Element

Syntax

 element.setAttributeNS(namespaceURI, name, value);

Parameters

namespaceURI

Data-type
String

The namespace URI of the attribute, or null.

name

Data-type
String

The local name of the attribute within the specified namespace.

value

Data-type
String

The value of the attribute.

Return Value

No return value

Usage

 Use this method to set an attribute in a specified namespace.

Notes

  • The attribute will be created, if it is not already present.
  • Where namespaces are irrelevant, setAttribute can be used instead.

Related specifications

Document Object Model (DOM) Level 3 Core
Recommendation
Document Object Model (DOM) Level 2 Core
Recommendation
DOM
Living Standard

Attributions