<!--
{
  "availability" : [
    "macOS: 10.0.0 -",
    "swift: -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/NSAttributedString/init(HTML:options:documentAttributes:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSAttributedString(im)initWithHTML:options:documentAttributes:"
  },
  "title" : "init(HTML:options:documentAttributes:)"
}
-->

# init(HTML:options:documentAttributes:)

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

```
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

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

## Discussion

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)