Programmer's Guide > Interfaces > W3C Document interface > createElement method
  
createElement method
Creates an element of the type specified. Note that the instance returned implements the Element interface, so attributes can be specified directly on the returned object.
In addition, if there are known attributes with default values, Attr nodes representing them are automatically created and attached to the element.
To create an element with a qualified name and namespace URI, use the createElementNS method.
createElement(tagName )
Parameters
StringtagName
The name of the element type to instantiate. For XML, this is case-sensitive. For HTML, the tagName parameter may be provided in any case, but it must be mapped to the canonical uppercase form by the DOM implementation.
Returns
Element. A new Element object with the nodeName attribute set to tagName, and localName, prefix, and namespaceURI set to null.
Throws
DOMException
INVALID_CHARACTER_ERR: Raised if the specified name contains an illegal character.