Export (0) Print
Expand All

Table.HorizontalAlign Property

Gets or sets the horizontal alignment of the Table control on the page.

Namespace:  System.Web.UI.WebControls
Assembly:  System.Web (in System.Web.dll)

public virtual HorizontalAlign HorizontalAlign { get; set; }

Property Value

Type: System.Web.UI.WebControls.HorizontalAlign
One of the HorizontalAlign enumeration values. The default value is NotSet.

Use the HorizontalAlign property to specify the horizontal alignment of the Table control within the page. The following table lists the different horizontal alignment styles.

HorizontalAlign value



The horizontal alignment of the Table control has not been set.


The Table control is left justified on the page.


The Table control is centered on the page.


The Table control is right justified on the page.


The Table control is aligned with both the left and right margins of the page.

<%@ Page Language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 

<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head2" runat="server">
    <title>Table - C# Example</title>
    <form id="form1" runat="server">

    <h3>Table - C# Example</h3>

    <asp:Table id="Table1" runat="server" 
      GridLines="Both" BackImageUrl="image1.gif" 
      HorizontalAlign="Center" CellSpacing="3" 
        <asp:TableCell>Row 0, Col 0</asp:TableCell>
        <asp:TableCell>Row 0, Col 1</asp:TableCell>
        <asp:TableCell>Row 1, Col 0</asp:TableCell>
        <asp:TableCell>Row 1, Col 1</asp:TableCell>


.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0, 1.1
© 2015 Microsoft