---
title: "loadHTMLString(_:baseURL:)"
framework: webkit
role: symbol
role_heading: Instance Method
path: "webkit/webframe/loadhtmlstring(_:baseurl:)"
---

# loadHTMLString(_:baseURL:)

Sets the main page contents and base URL.

## Declaration

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

## Parameters

- `string`: The string to use as the main page for the document. Since the string is treated as a webpage with UTF-8 encoding, the default encoding for any script elements referenced by the HTML is also UTF-8. To avoid this, include a character set attribute on the script element.
- `URL`: A file that is used to resolve relative URLs within the document.

## See Also

### Loading Content

- [load(_:)](webkit/webframe/load(_:)-47p2s.md)
- [reload()](webkit/webframe/reload().md)
- [reloadFromOrigin()](webkit/webframe/reloadfromorigin().md)
- [stopLoading()](webkit/webframe/stoploading().md)
- [loadAlternateHTMLString(_:baseURL:forUnreachableURL:)](webkit/webframe/loadalternatehtmlstring(_:baseurl:forunreachableurl:).md)
- [load(_:mimeType:textEncodingName:baseURL:)](webkit/webframe/load(_:mimetype:textencodingname:baseurl:).md)
- [load(_:)](webkit/webframe/load(_:)-6wkx6.md)
