## ASP.NET Panel HorizontalAlign Property
The `HorizontalAlign` property is a member of the `Panel` web control in ASP.NET. It is used to specify or retrieve the horizontal alignment of the contents inside a `Panel` control.
---
## Definition and Usage
The `HorizontalAlign` property determines how text, images, and other child controls are aligned horizontally within the boundaries of the `Panel` container.
By default, the alignment is determined by the browser's default settings or inherited CSS styles unless explicitly set.
---
## Syntax
```xml
```
### Property Values
| Value | Description |
| :--- | :--- |
| `NotSet` | The default value. The horizontal alignment is not explicitly set. The browser will use its default alignment behavior (typically left-aligned for left-to-right languages). |
| `Left` | Aligns the contents of the panel to the left edge. |
| `Center` | Centers the contents of the panel horizontally. |
| `Right` | Aligns the contents of the panel to the right edge. |
| `Justify` | Justifies the contents of the panel, stretching the lines so that each line has equal width (like in newspapers or magazines). |
---
## Code Example
The following example demonstrates how to set the `HorizontalAlign` property of an ASP.NET `Panel` control to align its content to the right.
```xml
<%@ Page Language="C#" %>
Panel HorizontalAlign Example
```
---
## Technical Considerations
* **Rendered HTML:** When the ASP.NET engine renders the `Panel` control to the browser, it translates the `Panel` into an HTML `
` element. The `HorizontalAlign` property is typically rendered as an inline CSS style (e.g., `style="text-align:right;"`) or as an HTML `align` attribute depending on the target .NET Framework rendering mode.
* **Block vs. Inline Elements:** The `HorizontalAlign` property affects inline elements (like text, images, or inline-block controls) inside the panel. If you place block-level elements (like another `
` or a nested `Panel` without specified widths) inside, they may still span the full width of the container, though their inline content will respect the alignment.
* **CSS Alternative:** In modern web development, it is often recommended to manage layout and alignment using external CSS classes (via the `CssClass` property) rather than setting inline presentation properties like `HorizontalAlign` directly in the markup.