YouTip LogoYouTip

Prop Webcontrol Checkboxlist Cellspacing

## ASP.NET CheckBoxList CellSpacing Property The `CellSpacing` property is a member of the `CheckBoxList` control in ASP.NET. It is used to get or set the amount of space (in pixels) between individual cells in the rendered table layout. --- ## Definition and Usage The `CellSpacing` property defines the spacing between the cells of the `CheckBoxList` control. > **Note:** This property is only applicable and effective when the `RepeatLayout` property of the `CheckBoxList` is set to `Table` (which is the default layout mode). If `RepeatLayout` is set to `Flow`, `Ul`, or `Ol`, this property will have no visual effect. --- ## Syntax ```xml ``` ### Property Values | Value | Description | | :--- | :--- | | `pixels` | An integer value specifying the distance (in pixels) between table cells. | --- ## Code Example The following example demonstrates how to set the `CellSpacing` property of an ASP.NET `CheckBoxList` control to `15` pixels to create visible separation between the checkbox items. ```xml <%@ Page Language="C#" %> CheckBoxList CellSpacing Example

CheckBoxList CellSpacing Demo

``` --- ## Key Considerations 1. **Layout Dependency:** Always ensure that `RepeatLayout="Table"` (default) is active when using `CellSpacing`. In modern web development, if you prefer semantic HTML (like `
    ` or `
    ` tags) over tables, you should manage spacing using CSS (`margin` or `gap` properties) instead of `CellSpacing`. 2. **Difference between CellSpacing and CellPadding:** * `CellSpacing` controls the space **between** adjacent cells. * `CellPadding` controls the space **inside** a cell (between the cell border and the checkbox/text content).
    ← Prop Webcontrol Checkboxlist RProp Webcontrol Checkboxlist C β†’