# Javascript: Selection.setFormattingStyle Method

> Sets the formatting style of the selected text.

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

---

### Description

Sets the formatting style of the selected text.

### Syntax

```javascript
<void> Selection.setFormattingStyle(<string> formattingStyle, [<EmptyRequestCallback> callback], [<ErrorCallback> errorCallback])
```

### Parameters

| Parameter | Description |
|---|---|
| formattingStyle | The formatting style of the selected text. |
| 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.setFormattingStyle` in a practical document-editing workflow. It sets the formatting style of the selected text.

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

TXTextControl.selection.setFormattingStyle(
    "MM/dd/yyyy",
    function() {
        console.log("set formatting style completed.");
    },
    onTxError
);
```

---

## Nearby

- **Previous:** [Javascript: Selection.setForeColor Method](https://docs.textcontrol.com/ds-server/reference/javascript/selection/setforecolor-method/llms-full.txt)
- **Next:** [Javascript: Selection.setItalic Method](https://docs.textcontrol.com/ds-server/reference/javascript/selection/setitalic-method/llms-full.txt)
