This documentation is archived and is not being maintained.

HtmlElement.OuterHtml Property

Note: This property is new in the .NET Framework version 2.0.

Gets or sets the current element's HTML code.

Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in system.windows.forms.dll)

public string OuterHtml { get; set; }
/** @property */
public String get_OuterHtml ()

/** @property */
public void set_OuterHtml (String value)

public function get OuterHtml () : String

public function set OuterHtml (value : String)

Property Value

The HTML code for the current element and its children.

Whereas InnerHtml will return all HTML contained in the current element excluding the current element's surrounding tags, OuterHtml includes the current element's tag as well as the HTML that tag contains, for example:

<HTML>

<BODY>

<DIV id="div1">

Hello

<DIV id="div2">

World

<DIV id="div3">

How are you?

</DIV>

</DIV>

</DIV>

</BODY>

</HTML>

In this example, calling OuterHtml on div2 will return:

<DIV id="div2">

World

<DIV id="div3">

How are you?

</DIV>

</DIV>

Calling InnerHtml will return:

World

<DIV id="div3">

How are you?

</DIV>

If you assign a new value to OuterHtml, the current element reference will become invalid; it will not reflect the name, properties and child content of the HTML you have just assigned.

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0
Show: