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

# init(HTML:baseURL:documentAttributes:)

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

```
init?(HTML data: Data, baseURL base: URL, documentAttributes dict: AutoreleasingUnsafeMutablePointer<NSDictionary?>?)
```

## Parameters

`data`

A data object with text in HTML format. The method uses this data to create the attributed string.

`base`

An [`NSURL`](/documentation/Foundation/NSURL) that represents the base URL for all links within the HTML.

`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> Note:
> Apple discourages the use of this symbol. Use ``doc://com.apple.foundation/documentation/Foundation/NSAttributedString/loadFromHTML(data:options:completionHandler:)`` instead.

---

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)