<!--
{
  "availability" : [
    "iOS: 8.0.0 -",
    "iPadOS: 8.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.10.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "WebKit",
  "identifier" : "/documentation/WebKit/WKWebView/loadHTMLString(_:baseURL:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "WebKit"
    ],
    "preciseIdentifier" : "c:objc(cs)WKWebView(im)loadHTMLString:baseURL:"
  },
  "title" : "loadHTMLString(_:baseURL:)"
}
-->

# loadHTMLString(_:baseURL:)

Loads the contents of the specified HTML string and navigates to it.

```
func loadHTMLString(_ string: String, baseURL: URL?) -> WKNavigation?
```

## Parameters

`string`

The string to use as the contents of the webpage.

`baseURL`

The base URL to use when the system resolves relative URLs within the HTML string.

## Return Value

A new navigation object you use to track the loading progress of the request.

## Discussion

Use this method to navigate to a webpage that you loaded or created yourself. For example, you might use this method to load HTML content that your app generates programmatically.

This method sets the source of this load request for app activity data to <doc://com.apple.documentation/documentation/Foundation/NSURLRequest/Attribution-swift.enum/developer>.

---

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)
