HtmlDocument.Body Property


Gets the HtmlElement for the BODY tag.

 property System::Windows::Forms::HtmlElement ^ Body { System::Windows::Forms::HtmlElement ^ get(); };
public System.Windows.Forms.HtmlElement Body { get; }
member this.Body : System.Windows.Forms.HtmlElement
Public ReadOnly Property Body As HtmlElement

Property Value


The HtmlElement object for the BODY tag.


The following code example creates a new DIV element and appends it to the bottom of the document using the AppendChild method.

private void AppendText(String text)
    if (webBrowser1.Document != null)
        HtmlDocument doc = webBrowser1.Document;
        HtmlElement textElem = doc.CreateElement("DIV");
        textElem.InnerText = text;
Private Sub AppendText(ByVal Text As String)
    If (WebBrowser1.Document IsNot Nothing) Then
        With WebBrowser1.Document
            Dim TextElem As HtmlElement = .CreateElement("DIV")
            TextElem.InnerText = Text
        End With
    End If
End Sub


An HTML document is split into two major sections:

  • HEAD, which contains the document's title, any document meta-data, and SCRIPT elements.

  • BODY, which contains all of the elements involved in the on-screen appearance of the document.

There is no equivalent Head property on HtmlDocument. To obtain the HEAD element, use GetElementsByTagName.

Applies to

See also