Prop Webcontrol Calendar Captionalign
## ASP.NET Web Control: Calendar CaptionAlign Property
The `CaptionAlign` property is a key styling feature of the ASP.NET Web Control `Calendar`. It allows developers to specify the alignment and positioning of the calendar's caption text relative to the calendar grid.
---
## Definition and Usage
The `CaptionAlign` property is used to set or return the alignment of the caption text in a `Calendar` control.
When you define a `Caption` for your calendar (which acts as an accessible header or title for screen readers and visual users), the `CaptionAlign` property determines where and how that text is rendered.
---
## Syntax
```xml
```
### Property Values
The `CaptionAlign` property accepts values defined by the `TableCaptionAlign` enumeration:
| Value | Description |
| :--- | :--- |
| **NotSet** | The alignment is not set. The browser will render the caption using its default alignment (typically centered at the top). |
| **Top** | Positions the caption text at the top of the calendar. The text is centered. |
| **Bottom** | Positions the caption text at the bottom of the calendar. The text is centered. |
| **Left** | Positions the caption text at the top of the calendar, aligned to the left. |
| **Right** | Positions the caption text at the top of the calendar, aligned to the right. |
---
## Code Example
The following example demonstrates how to set the `Caption` property of a Calendar control and align it to the bottom of the calendar using the `CaptionAlign` property.
### ASPX Markup
```xml
<%@ Page Language="C#" %>
ASP.NET Calendar CaptionAlign Example
```
---
## Technical Considerations
1. **Accessibility (WCAG/Section 508):** Using the `Caption` and `CaptionAlign` properties is highly recommended for web accessibility. It renders an HTML `` element inside the generated table, which helps screen readers identify the purpose of the calendar grid.
2. **CSS Overrides:** While `CaptionAlign` provides quick declarative positioning, you can also style the caption using external CSS by targeting the `caption` selector inside the calendar's table structure.
3. **Default Behavior:** If the `Caption` property is empty or not specified, setting `CaptionAlign` will have no visible effect on the page.
YouTip