---
title: "init(HTML:options:documentAttributes:)"
framework: foundation
role: symbol
role_heading: Initializer
path: "foundation/nsattributedstring/init(html:options:documentattributes:)"
---

# init(HTML:options:documentAttributes:)

Creates an attributed string from the HTML in the specified data object.

## Declaration

```swift
init?(HTML data: Data, options: [NSAttributedString.DocumentReadingOptionKey : Any] = [:], documentAttributes dict: AutoreleasingUnsafeMutablePointer<NSDictionary?>?)
```

```swift
init?(html data: Data, options: [NSAttributedString.DocumentReadingOptionKey : Any] = [:], documentAttributes dict: AutoreleasingUnsafeMutablePointer<NSDictionary?>?)
```

## 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.
- `dict`: An in-out dictionary containing document-level attributes. On output, this method updates the dictionary to contain any document-specific keys found in the data. Specify nil if you don’t want the document attributes.

## Return Value

Return Value Returns an initialized object, or nil if the data can’t be decoded.

## 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)
- [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)
- [loadFromHTML(data:options:completionHandler:)](foundation/nsattributedstring/loadfromhtml(data:options:completionhandler:).md)
- [NSAttributedString.CompletionHandler](foundation/nsattributedstring/completionhandler.md)
