System.Windows.Forms.HtmlDocument.CreateElement Method

Creates a new HtmlElement of the specified HTML tag type.

Syntax

public HtmlElement CreateElement (string elementTag)

Parameters

elementTag
The name of the HTML element to create.

Returns

A new element of the specified tag type.

Remarks

elementTag may be one of any of the supported HTML tags in Internet Explorer, except for FRAME or IFRAME.

HtmlDocument.CreateElement(string) returns an element unattached to the current document tree. To add the element to the document, use either the HtmlElement.InsertAdjacentElement(HtmlElementInsertionOrientation, HtmlElement) or HtmlElement.AppendChild(HtmlElement) methods.

This method will not affect the state of an existing document's source code when you use the System.Windows.Forms.WebBrowser control's View Source context menu command or the WebBrowser.DocumentText and WebBrowser.DocumentStream properties of the System.Windows.Forms.WebBrowser control.

When you create new elements with HtmlDocument.CreateElement(string), you will not be able to set certain properties, such as Name. In cases where you need to set the Name attribute, assign them as HTML to the HtmlElement.InnerHtml property of another object in the document.

Requirements

Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
Assembly Versions: 2.0.0.0