---
title: "applyStyle(_:)"
framework: webkit
role: symbol
role_heading: Instance Method
path: "webkit/webview-swift.class/applystyle(_:)"
---

# applyStyle(_:)

Applies the CSS typing style to the current selection.

## Declaration

```swift
func applyStyle(_ style: DOMCSSStyleDeclaration!)
```

## Parameters

- `style`: The style to apply to the current selection.

## Discussion

Discussion This method does nothing if there is no current selection or if the current selection is collapsed. This method hides the complexities of applying styles to elements. If necessary, this method will make multiple passes over the range of the current selection to ensure that the requested style is applied to the elements in that range, and takes into account the complexities of CSS style application rules. This method also simplifies styling attributes so that the minimum number of styling directives are used to yield a given computed style.

## See Also

### Getting and Setting CSS Properties

- [computedStyle(for:pseudoElement:)](webkit/webview-swift.class/computedstyle(for:pseudoelement:).md)
- [mediaStyle](webkit/webview-swift.class/mediastyle.md)
- [typingStyle](webkit/webview-swift.class/typingstyle.md)
- [styleDeclaration(withText:)](webkit/webview-swift.class/styledeclaration(withtext:).md)
