---
title: backgroundColor
framework: foundation
role: symbol
role_heading: Type Property
path: foundation/nsattributedstring/documentattributekey/backgroundcolor
---

# backgroundColor

The background color of the document.

## Declaration

```swift
static let backgroundColor: NSAttributedString.DocumentAttributeKey
```

## Discussion

Discussion The value of this attribute is an NSColor object representing the document-wide page background color. The string constant in macOS 10.3 and earlier is @"BackgroundColor". For applications linked on versions prior to macOS 10.5, HTML import sets the NSBackgroundColorDocumentAttribute to [NSColor whiteColor] in cases in which the HTML does not specify a background color. For applications linked on macOS 10.5 and later, no NSBackgroundColorDocumentAttribute is set in these cases.

## See Also

### Getting document appearance keys

- [appearance](foundation/nsattributedstring/documentattributekey/appearance.md)
- [bottomMargin](foundation/nsattributedstring/documentattributekey/bottommargin.md)
- [defaultFontExcluded](foundation/nsattributedstring/documentattributekey/defaultfontexcluded.md)
- [defaultTabInterval](foundation/nsattributedstring/documentattributekey/defaulttabinterval.md)
- [excludedElements](foundation/nsattributedstring/documentattributekey/excludedelements.md)
- [hyphenationFactor](foundation/nsattributedstring/documentattributekey/hyphenationfactor.md)
- [leftMargin](foundation/nsattributedstring/documentattributekey/leftmargin.md)
- [paperMargin](foundation/nsattributedstring/documentattributekey/papermargin.md)
- [paperSize](foundation/nsattributedstring/documentattributekey/papersize.md)
- [prefixSpaces](foundation/nsattributedstring/documentattributekey/prefixspaces.md)
- [rightMargin](foundation/nsattributedstring/documentattributekey/rightmargin.md)
- [textLayoutSections](foundation/nsattributedstring/documentattributekey/textlayoutsections.md)
- [topMargin](foundation/nsattributedstring/documentattributekey/topmargin.md)
- [viewMode](foundation/nsattributedstring/documentattributekey/viewmode.md)
- [viewSize](foundation/nsattributedstring/documentattributekey/viewsize.md)
