Creates the HTML element specified by the tag name.
This is similar to Document.createElement. tag
should be a valid HTML tag name. If tag
is an unknown tag then this will create an UnknownElement.
var divElement = new Element.tag('div'); print(divElement is DivElement); // 'true' var myElement = new Element.tag('unknownTag'); print(myElement is UnknownElement); // 'true'
For standard elements it is better to use the element type constructors:
var element = new DivElement();
It is better to use e.g new CanvasElement()
because the type of the expression is CanvasElement
, whereas the type of Element.tag
is the less specific Element
.
See also:
factory Element.tag(String tag, [String typeExtention]) => _ElementFactoryProvider.createElement_tag(tag, typeExtention);
© 2012 the Dart project authors
Licensed under the Creative Commons Attribution-ShareAlike License v4.0.
https://api.dart.dev/stable/2.5.0/dart-html/Element/Element.tag.html