<!--
{
  "availability" : [
    "iOS: 2.0.0 - 12.0.0",
    "iPadOS: 2.0.0 - 12.0.0"
  ],
  "documentType" : "symbol",
  "framework" : "UIKit",
  "identifier" : "/documentation/UIKit/UIWebView/loadHTMLString(_:baseURL:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "UIKit"
    ],
    "preciseIdentifier" : "c:objc(cs)UIWebView(im)loadHTMLString:baseURL:"
  },
  "title" : "loadHTMLString(_:baseURL:)"
}
-->

# loadHTMLString(_:baseURL:)

Sets the main page content and base URL.

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

## Parameters

`string`

The content for the main page.

`baseURL`

The base URL for the content.

## Discussion

To help you avoid being vulnerable to security attacks, be sure to use this method to load local HTML files; don’t use [`loadRequest(_:)`](/documentation/UIKit/UIWebView/loadRequest(_:)).

---

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)