<!--
{
  "availability" : [
    "macOS: 10.3.0 - 10.14.0"
  ],
  "documentType" : "symbol",
  "framework" : "WebKit",
  "identifier" : "/documentation/WebKit/WebPreferences",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "WebKit"
    ],
    "preciseIdentifier" : "c:objc(cs)WebPreferences"
  },
  "title" : "WebPreferences"
}
-->

# WebPreferences

WebPreferences encapsulates the preferences you can change per WebView object. These preferences include font, text encoding, and image settings. Normally a WebView object uses the standard preferences returned by the [`standard()`](/documentation/WebKit/WebPreferences/standard()) class method. However, you can modify the preferences for individual WebView instances too. Use the [`preferencesIdentifier`](/documentation/WebKit/WebView-swift.class/preferencesIdentifier) WebView method to change a WebView object’s preferences, or to share preferences between WebView objects. Use the [`autosaves`](/documentation/WebKit/WebPreferences/autosaves) method to specify if the preferences object should be automatically saved to the user defaults database.

```
class WebPreferences
```

## Overview

WebPreferences also manages the font preferences for a web view. You can set custom font families for each of the primary web font styles (standard, serif, sans-serif, cursive, and fantasy) as well as their font sizes. The font size preferences alter the display font sizes in a certain way. If the HTML or CSS in the web view’s content specifies font sizes in a relative fashion (such as `font size=-1` in HTML or `font-size: medium` in CSS), the default font size settings (set by the font size methods prefaced with “default”) have an effect. They do not have an effect for font sizes specified absolutely. The values specified by the minimum font size settings (set by the font size methods prefaced with “minimum”) override all the HTML and CSS font size definitions, and so have an effect on the entirety of the content. The values specified by the minimum logical font size settings (set by the font size methods prefaced with “minimumLogical”) affect all relative font size declarations for HTML and CSS, but also override any CSS font size declarations in the content, whether they are relative or absolute.

The font size for a web view is different than its logical font size. The minimum logical font size, for example, is the absolute minimum size at which the font will display onscreen. This is meant to be a functional boundary and not a style boundary. For example, the default value for a web view’s minimum logical font size is 9 points, because typical web content looks good in macOS at font sizes of 9 point and above. The constraint assures that web content will always look good in a web view. If you know that your content will look good only at 12 points or above, you should change the minimum font size to 12 points and leave the minimum *logical* font size alone. This will assure that your content will never display at sizes less than 12 points, but the functional font size boundary of the web view will remain at 9 points to prevent any chance of displaying unnecessarily small text.

## Topics

### Getting the Standard Preferences

[`+  standardPreferences`](/documentation/WebKit/WebPreferences/standard())

Returns the standard set of preferences that may be used by all WebView objects.

### Initializing Preferences

[`-  initWithIdentifier:`](/documentation/WebKit/WebPreferences/init(identifier:))

Returns an initialized `WebPreferences` object, creating one if it does not exist.

### Getting the Identifier

[`identifier`](/documentation/WebKit/WebPreferences/identifier)

The receiver’s identifier.

### Saving Preferences to the User Defaults Database

[`autosaves`](/documentation/WebKit/WebPreferences/autosaves)

A Boolean that indicates whether or not the receiver’s attributes are automatically stored in the user defaults database.

### Enabling Java

[`javaEnabled`](/documentation/WebKit/WebPreferences/isJavaEnabled)

A Boolean that indicates whether or not the web view allows Java.

### Enabling JavaScript

[`javaScriptEnabled`](/documentation/WebKit/WebPreferences/isJavaScriptEnabled)

A Boolean that indicates whether or not the web view allows JavaScript.

[`javaScriptCanOpenWindowsAutomatically`](/documentation/WebKit/WebPreferences/javaScriptCanOpenWindowsAutomatically)

A Boolean that indicates whether or not the web view allows JavaScript to open windows automatically.

### Enabling Plug-ins

[`plugInsEnabled`](/documentation/WebKit/WebPreferences/arePlugInsEnabled)

A Boolean that indicates whether or not the web view allows plug-ins.

### Enabling Style Sheets

[`userStyleSheetEnabled`](/documentation/WebKit/WebPreferences/userStyleSheetEnabled)

A Boolean that indicates whether or not user style sheets are enabled in the web view.

### Getting and Setting Fonts

[`cursiveFontFamily`](/documentation/WebKit/WebPreferences/cursiveFontFamily)

The cursive font family of the web view.

[`fantasyFontFamily`](/documentation/WebKit/WebPreferences/fantasyFontFamily)

The fantasy font family of the web view.

[`fixedFontFamily`](/documentation/WebKit/WebPreferences/fixedFontFamily)

The fixed font family of the web view.

[`sansSerifFontFamily`](/documentation/WebKit/WebPreferences/sansSerifFontFamily)

The sans serif font family of the web view.

[`serifFontFamily`](/documentation/WebKit/WebPreferences/serifFontFamily)

The serif font family of the web view.

[`standardFontFamily`](/documentation/WebKit/WebPreferences/standardFontFamily)

The standard font family of the web view.

### Getting and Setting Font Sizes

[`defaultFixedFontSize`](/documentation/WebKit/WebPreferences/defaultFixedFontSize)

The default fixed font size of the web view.

[`defaultFontSize`](/documentation/WebKit/WebPreferences/defaultFontSize)

The default font size of the web view.

[`minimumFontSize`](/documentation/WebKit/WebPreferences/minimumFontSize)

The minimum font size of the web view.

[`minimumLogicalFontSize`](/documentation/WebKit/WebPreferences/minimumLogicalFontSize)

The minimum logical font size of the web view.

### Getting and Setting Text Encoding

[`defaultTextEncodingName`](/documentation/WebKit/WebPreferences/defaultTextEncodingName)

The default text encoding of the web view.

### Getting and Setting Incremental Rendering

[`suppressesIncrementalRendering`](/documentation/WebKit/WebPreferences/suppressesIncrementalRendering)

A Boolean that indicates whether incremental rendering should be suppressed.

### Handling Images

[`allowsAnimatedImageLooping`](/documentation/WebKit/WebPreferences/allowsAnimatedImageLooping)

A Boolean that indicates whether or not the receiver allows animated images to loop.

[`allowsAnimatedImages`](/documentation/WebKit/WebPreferences/allowsAnimatedImages)

A Boolean that indicates whether or not the receiver allows animated images.

[`loadsImagesAutomatically`](/documentation/WebKit/WebPreferences/loadsImagesAutomatically)

A Boolean that indicates whether or not the web view allows images to be loaded automatically.

### Printing Backgrounds

[`shouldPrintBackgrounds`](/documentation/WebKit/WebPreferences/shouldPrintBackgrounds)

A Boolean that indicates whether or not the web view should include backgrounds when printing.

### Enabling Private Browsing

[`privateBrowsingEnabled`](/documentation/WebKit/WebPreferences/privateBrowsingEnabled)

A Boolean that indicates whether or not private browsing is enabled.

### Controlling User Focus

[`tabsToLinks`](/documentation/WebKit/WebPreferences/tabsToLinks)

A Boolean that indicates whether or not the tab key will focus links.

### Caching

[`usesPageCache`](/documentation/WebKit/WebPreferences/usesPageCache)

A Boolean that indicates whether the web views associated with the receiver should use the shared page cache.

[`cacheModel`](/documentation/WebKit/WebPreferences/cacheModel)

The cache model for the web views associated with the receiver.

### Constants

[`WebCacheModel`](/documentation/WebKit/WebCacheModel)

Specifies the caching model for a web view.

### Notifications

  <doc://com.apple.documentation/documentation/Foundation/NSNotification/Name-swift.struct/WebPreferencesChanged>

### Notifications

[`WebPreferencesChangedNotification`](/documentation/WebKit/WebPreferencesChangedNotification)

Posted when the web preference settings are changed.

## Relationships

### Conforms To

[`CVarArg`](/documentation/Swift/CVarArg)

[`NSObjectProtocol`](/documentation/ObjectiveC/NSObjectProtocol)

[`Hashable`](/documentation/Swift/Hashable)

[`CustomStringConvertible`](/documentation/Swift/CustomStringConvertible)

[`Equatable`](/documentation/Swift/Equatable)

[`NSCoding`](/documentation/Foundation/NSCoding)

[`CustomDebugStringConvertible`](/documentation/Swift/CustomDebugStringConvertible)

### Inherits From

[`NSObject-swift.class`](/documentation/ObjectiveC/NSObject-swift.class)

---

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)