---
title: "loadFromHTML(data:options:completionHandler:)"
framework: foundation
role: symbol
role_heading: Type Method
path: "foundation/nsattributedstring/loadfromhtml(data:options:completionhandler:)"
---

# loadFromHTML(data:options:completionHandler:)

Creates an attributed string from the specified HTML data.

## Declaration

```swift
class func loadFromHTML(data: Data, options: [NSAttributedString.DocumentReadingOptionKey : Any] = [:], completionHandler: @escaping @Sendable (NSAttributedString?, [NSAttributedString.DocumentAttributeKey : Any]?, (any Error)?) -> Void)
```

```swift
class func fromHTML(_ data: Data, options: [NSAttributedString.DocumentReadingOptionKey : Any] = [:]) async throws -> (NSAttributedString, [NSAttributedString.DocumentAttributeKey : Any])
```

## Parameters

- `data`: A data object with text in HTML format. The method uses this data to create the attributed string.
- `options`: Specifies additional options for loading the document. For a list of possible keys, see doc://com.apple.documentation/documentation/UIKit/NSAttributedStringDocumentReadingOptionKey.
- `completionHandler`: A completion handler to execute with the results.

## See Also

### Creating from HTML

- [init(HTML:documentAttributes:)](foundation/nsattributedstring/init(html:documentattributes:).md)
- [init(HTML:baseURL:documentAttributes:)](foundation/nsattributedstring/init(html:baseurl:documentattributes:).md)
- [init(HTML:options:documentAttributes:)](foundation/nsattributedstring/init(html:options:documentattributes:).md)
- [loadFromHTML(request:options:completionHandler:)](foundation/nsattributedstring/loadfromhtml(request:options:completionhandler:).md)
- [loadFromHTML(fileURL:options:completionHandler:)](foundation/nsattributedstring/loadfromhtml(fileurl:options:completionhandler:).md)
- [loadFromHTML(string:options:completionHandler:)](foundation/nsattributedstring/loadfromhtml(string:options:completionhandler:).md)
- [NSAttributedString.CompletionHandler](foundation/nsattributedstring/completionhandler.md)
