---
title: WebDocumentText
framework: webkit
role: symbol
role_heading: Protocol
path: webkit/webdocumenttext
---

# WebDocumentText

WebDocumentText is an optional protocol for document view objects that display text. This protocol defines methods for accessing document content as strings, and methods for text selection. Classes that adopt this protocol should also adopt WebDocumentView and inherit from NSView.

## Declaration

```swift
protocol WebDocumentText : NSObjectProtocol
```

## Topics

### Getting document content

- [string()](webkit/webdocumenttext/string().md)
- [attributedString()](webkit/webdocumenttext/attributedstring().md)

### Selecting and deselecting text

- [selectAll()](webkit/webdocumenttext/selectall().md)
- [deselectAll()](webkit/webdocumenttext/deselectall().md)
- [selectedString()](webkit/webdocumenttext/selectedstring().md)
- [selectedAttributedString()](webkit/webdocumenttext/selectedattributedstring().md)

### Text encoding

- [supportsTextEncoding()](webkit/webdocumenttext/supportstextencoding().md)

## Relationships

### Inherits From

- [NSObjectProtocol](objectivec/nsobjectprotocol.md)

## See Also

### Working With Document Web Views (Legacy)

- [WebDocumentRepresentation](webkit/webdocumentrepresentation.md)
- [WebDocumentSearching](webkit/webdocumentsearching.md)
- [WebDocumentView](webkit/webdocumentview.md)
