System.Web.UI.HtmlControls.HtmlTableCell Class

Represents the <td> and <th> HTML elements in an System.Web.UI.HtmlControls.HtmlTableRow object.

See Also: HtmlTableCell Members


public class HtmlTableCell : HtmlContainerControl


The <td> element represents a data cell in a table, while the <th> element represents a table heading cell. Use the System.Web.UI.HtmlControls.HtmlTableCell class to programmatically control the <td> and <th> HTML elements in an System.Web.UI.HtmlControls.HtmlTableRow object.

The System.Web.UI.HtmlControls.HtmlTableCell class allows you to customize the appearance of a cell in a table by specifying the background color, the border color, the height, and the width. These attributes are set using the HtmlTableCell.BgColor, HtmlTableCell.BorderColor, HtmlTableCell.Height, and HtmlTableCell.Width properties.

You can control how the content of a cell is displayed by specifying the vertical and horizontal alignment of the contents. You can also specify whether the content automatically continues on the next line when the end of the cell is reached. The horizontal alignment is controlled by the HtmlTableCell.Align property, while the HtmlTableCell.VAlign property controls the vertical alignment. The HtmlTableCell.NoWrap property indicates whether text wrapping is disabled.

By using the HtmlTableCell.ColSpan or the HtmlTableCell.RowSpan property, you can control the number of columns or rows that a cell occupies. For example, you can create a cell that occupies two columns in a table by setting the HtmlTableCell.ColSpan property to 2.

For a list of initial property values for an instance of System.Web.UI.HtmlControls.HtmlTableCell, see the HtmlTableCell.#ctor constructor.


This control can be used to display user input, which might include malicious client script. Check any information that is sent from a client for executable script, SQL statements, or other code before displaying it in your application. ASP.NET provides an input request validation feature to block script and HTML in user input. Validation server controls are also provided to assess user input. For more information, see Validation Server Controls.


Namespace: System.Web.UI.HtmlControls
Assembly: System.Web (in System.Web.dll)
Assembly Versions: 1.0.5000.0,