# Customizing the Margins and Spacing of the Cell

Learn how you can customize the margins within a cell and the spacing between cells in a sheet using Spread for ASP.NET.

## Content

You can customize the margins within a cell and the spacing between cells in a sheet. The cell margin is the distance between the cell border and the cell contents and is specified for all four sides of a cell (or table cell in the displayed HTML). The cell spacing is the distance between the cells and is specified for the entire sheet (or table in the displayed HTML).
![Cell Spacing Terminology](https://cdn.mescius.io/document-site-files/images/346c9178-0ed8-4fb9-908b-1565b22fb408/artwork/cells-spacing.png)
To set the cell margin (or padding) use the [Margin](/spreadnet/api/latest/online-asp/FarPoint.Web.Spread/FarPoint.Web.Spread.Cell.Margin.html) property in the [Cell](/spreadnet/api/latest/online-asp/FarPoint.Web.Spread/FarPoint.Web.Spread.Cell.html) (or [Column](/spreadnet/api/latest/online-asp/FarPoint.Web.Spread/FarPoint.Web.Spread.Column.html) or [Row](/spreadnet/api/latest/online-asp/FarPoint.Web.Spread/FarPoint.Web.Spread.Row.html)) class, or set the [Margin](/spreadnet/api/latest/online-asp/FarPoint.Web.Spread/FarPoint.Web.Spread.StyleInfo.Margin.html) property in the [StyleInfo](/spreadnet/api/latest/online-asp/FarPoint.Web.Spread/FarPoint.Web.Spread.StyleInfo.html) class and apply the style to the cell or cells.
To set the cell spacing for the entire sheet, use the [CellSpacing](/spreadnet/api/latest/online-asp/FarPoint.Web.Spread/FarPoint.Web.Spread.SheetView.CellSpacing.html) property in the Sheet or set the [CellSpacing](/spreadnet/api/latest/online-asp/FarPoint.Web.Spread/FarPoint.Web.Spread.SheetSkin.CellSpacing.html) property in the [SheetSkin](/spreadnet/api/latest/online-asp/FarPoint.Web.Spread/FarPoint.Web.Spread.SheetSkin.html) class and apply the skin to the sheet or sheets.
To set the border, use the [Border](/spreadnet/api/latest/online-asp/FarPoint.Web.Spread/FarPoint.Web.Spread.Cell.Border.html) property as described in [Customizing Cell Borders](/spreadnet/docs/latest/online-asp/overview/spweb-devguide/spweb-appearSet/spweb-appearCell/spweb-cellborder).

## Using a Shortcut

1. Set the Cell shortcut object [Margin](/spreadnet/api/latest/online-asp/FarPoint.Web.Spread/FarPoint.Web.Spread.Cell.Margin.html) property to the new margins.
2. Set the Sheet [CellSpacing](/spreadnet/api/latest/online-asp/FarPoint.Web.Spread/FarPoint.Web.Spread.SheetView.CellSpacing.html) property to the new cell spacing value.

## Example

This example code creates a cell margin and sets cell spacing for the sheet.

```csharp
FarPoint.Web.Spread.Cell mycell;
FarPoint.Web.Spread.Inset margin = new FarPoint.Web.Spread.Inset(20, 40, 50, 20);
mycell = FpSpread1.Cells[0, 0];
mycell.Value = "Margin";
mycell.Locked = true;
mycell.Margin = margin;
FpSpread1.ActiveSheetView.Rows[0].Height = 80;
FpSpread1.Sheets[0].CellSpacing = 5;
```

```vbnet
Dim mycell As FarPoint.Web.Spread.Cell
Dim margin As New FarPoint.Web.Spread.Inset(20, 40, 50, 20)
mycell = FpSpread1.Cells(0, 0)
mycell.Value = "Margin"
mycell.Locked = True
mycell.Margin = margin
FpSpread1.ActiveSheetView.Rows(0).Height = 80
FpSpread1.Sheets(0).CellSpacing = 5
```

## Using the Spread Designer

1. Select the **Settings** menu.
2. Select the cells to apply the changes to.
3. Use the following to set the margin:
    Select the **Cells, Columns, and Rows** icon under the **Other Settings** section.
    Click on the **Margin** property in the property grid to create an inset for the cell in pixel units.
    Click **OK** to apply the changes.
4. To apply the cell spacing, do the following:
    Select the **Settings** menu.
    Select the **SheetSkin** icon in the **Appearance Settings** section.
    Select the custom tab in the **SheetSkin** editor.
    Set **CellSpacing** in the **Misc.** section.
    Click **OK** to apply the changes.
5. Click **Apply and Exit** to close the Spread Designer.