Rediger

Del via


HtmlDocument.Body Property

Definition

Gets the HtmlElement for the BODY tag.

public:
 property System::Windows::Forms::HtmlElement ^ Body { System::Windows::Forms::HtmlElement ^ get(); };
public System.Windows.Forms.HtmlElement Body { 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.

Examples

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;
        doc.Body.AppendChild(textElem);
    }
}
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
            .Body.AppendChild(TextElem)
        End With
    End If
End Sub

Remarks

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