HtmlDocument.Body Property
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
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
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;
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
An HTML document is split into two major sections:
HEAD
, which contains the document's title, any document meta-data, andSCRIPT
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.
Product | Versions |
---|---|
.NET Framework | 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
Windows Desktop | 3.0, 3.1, 5, 6, 7, 8, 9, 10 |
.NET feedback
.NET is an open source project. Select a link to provide feedback: