# Javascript: Selection.setCharacterSpacing Method

> Sets the style's character spacing value, in twips. This value is added to each character. When it is negative, character spacing is reduced, otherwise it is extended.

- **Product:** DS Server
- **Section:** Reference
- **Kind:** Method
- **Introduced:** 30.0
- **Path:** DS Server > Reference > JavaScript API > Javascript: Selection.setCharacterSpacing Method
- **377 words**
- **Web URL:** https://docs.textcontrol.com/ds-server/reference/javascript/selection/setcharacterspacing-method/
- **LLMs URL:** https://docs.textcontrol.com/ds-server/reference/javascript/selection/setcharacterspacing-method/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/ds-server/reference/javascript/selection/setcharacterspacing-method/llms-full.txt

---

### Description

Sets the style's character spacing value, in twips. This value is added to each character. When it is negative, character spacing is reduced, otherwise it is extended.

### Syntax

```javascript
<void> Selection.setCharacterSpacing(<number> characterSpacing, [<EmptyRequestCallback> callback], [<ErrorCallback> errorCallback])
```

### Parameters

| Parameter | Description |
|---|---|
| characterSpacing | The new value. |
| callback | Optional. Is called when the operation completed. |
| errorCallback | Optional. Is called when the operation failed with an error. |

### Examples

The following example demonstrates `Selection.setCharacterSpacing` in a practical document-editing workflow. It sets the style's character spacing value, in twips. This value is added to each character. When it is negative, character spacing is reduced, otherwise it is extended.

```javascript
function onTxError(error) {
    console.error("TX Text Control error:", error.msg);
    error.handled = true;
}

TXTextControl.selection.setCharacterSpacing(
    1,
    function() {
        console.log("set character spacing completed.");
    },
    onTxError
);
```

---

## Nearby

- **Previous:** [Javascript: Selection.setCharacterScaling Method](https://docs.textcontrol.com/ds-server/reference/javascript/selection/setcharacterscaling-method/llms-full.txt)
- **Next:** [Javascript: Selection.setCulture Method](https://docs.textcontrol.com/ds-server/reference/javascript/selection/setculture-method/llms-full.txt)
