description

# Element.tag constructor Null safety

Element.tag(

1. String tag,
2. [String? typeExtension]

)

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:

- isTagSupported

## Implementation

    factory Element.tag(String tag, [String? typeExtension]) =>
        _ElementFactoryProvider.createElement_tag(tag, typeExtension);