---
title: NSAttributedString.Key
framework: foundation
role: symbol
role_heading: Structure
path: foundation/nsattributedstring/key
---

# NSAttributedString.Key

The attributes you apply to ranges of characters in an attributed string.

## Declaration

```swift
struct Key
```

## Discussion

Discussion The NSAttributedString.Key type defines the attributes you apply to ranges of characters in an attributed string. Some attributes provide information about how to render, lay out, or interpret the text, while other attributes provide transient or collaborative information. Attributes like the font, kern, and strokeColor contain information that the rendering system uses to display the text. Attributes like the spellingState, textHighlightStyle, or accessibilityCustomText contain semantic information from other parts of the system. Some of these semantic attributes also affect how the system renders the text, but they are transient attributes unlike the core rendering attributes.

## Topics

### Getting rendering attribute keys

- [backgroundColor](foundation/nsattributedstring/key/backgroundcolor.md)
- [baselineOffset](foundation/nsattributedstring/key/baselineoffset.md)
- [font](foundation/nsattributedstring/key/font.md)
- [foregroundColor](foundation/nsattributedstring/key/foregroundcolor.md)
- [glyphInfo](foundation/nsattributedstring/key/glyphinfo.md)
- [kern](foundation/nsattributedstring/key/kern.md)
- [ligature](foundation/nsattributedstring/key/ligature.md)
- [paragraphStyle](foundation/nsattributedstring/key/paragraphstyle.md)
- [strikethroughColor](foundation/nsattributedstring/key/strikethroughcolor.md)
- [strikethroughStyle](foundation/nsattributedstring/key/strikethroughstyle.md)
- [strokeColor](foundation/nsattributedstring/key/strokecolor.md)
- [strokeWidth](foundation/nsattributedstring/key/strokewidth.md)
- [superscript](foundation/nsattributedstring/key/superscript.md)
- [tracking](foundation/nsattributedstring/key/tracking.md)
- [underlineColor](foundation/nsattributedstring/key/underlinecolor.md)
- [underlineStyle](foundation/nsattributedstring/key/underlinestyle.md)
- [writingDirection](foundation/nsattributedstring/key/writingdirection.md)

### Getting text attribute keys

- [cursor](foundation/nsattributedstring/key/cursor.md)
- [link](foundation/nsattributedstring/key/link.md)
- [markedClauseSegment](foundation/nsattributedstring/key/markedclausesegment.md)
- [replacementIndex](foundation/nsattributedstring/key/replacementindex.md)
- [shadow](foundation/nsattributedstring/key/shadow.md)
- [spellingState](foundation/nsattributedstring/key/spellingstate.md)
- [suggestionHighlight](foundation/nsattributedstring/key/suggestionhighlight.md)
- [textAlternatives](foundation/nsattributedstring/key/textalternatives.md)
- [textEffect](foundation/nsattributedstring/key/texteffect.md)
- [textHighlightColorScheme](foundation/nsattributedstring/key/texthighlightcolorscheme.md)
- [textHighlightStyle](foundation/nsattributedstring/key/texthighlightstyle.md)
- [textItemTag](foundation/nsattributedstring/key/textitemtag.md)
- [toolTip](foundation/nsattributedstring/key/tooltip.md)

### Getting attachment attribute keys

- [adaptiveImageGlyph](foundation/nsattributedstring/key/adaptiveimageglyph.md)
- [attachment](foundation/nsattributedstring/key/attachment.md)

### Getting accessibility attribute keys

- [accessibilityAlignment](foundation/nsattributedstring/key/accessibilityalignment.md)
- [accessibilityAnnotationTextAttribute](foundation/nsattributedstring/key/accessibilityannotationtextattribute.md)
- [accessibilityAttachment](foundation/nsattributedstring/key/accessibilityattachment.md)
- [accessibilityAutocorrected](foundation/nsattributedstring/key/accessibilityautocorrected.md)
- [accessibilityBackgroundColor](foundation/nsattributedstring/key/accessibilitybackgroundcolor.md)
- [accessibilityCustomText](foundation/nsattributedstring/key/accessibilitycustomtext.md)
- [accessibilityFont](foundation/nsattributedstring/key/accessibilityfont.md)
- [accessibilityFontBoldAttribute](foundation/nsattributedstring/key/accessibilityfontboldattribute.md)
- [accessibilityFontItalicAttribute](foundation/nsattributedstring/key/accessibilityfontitalicattribute.md)
- [accessibilityForegroundColor](foundation/nsattributedstring/key/accessibilityforegroundcolor.md)
- [accessibilityLanguage](foundation/nsattributedstring/key/accessibilitylanguage.md)
- [accessibilityLink](foundation/nsattributedstring/key/accessibilitylink.md)
- [accessibilityListItemIndex](foundation/nsattributedstring/key/accessibilitylistitemindex.md)
- [accessibilityListItemLevel](foundation/nsattributedstring/key/accessibilitylistitemlevel.md)
- [accessibilityListItemPrefix](foundation/nsattributedstring/key/accessibilitylistitemprefix.md)
- [accessibilityMarkedMisspelled](foundation/nsattributedstring/key/accessibilitymarkedmisspelled.md)
- [accessibilityMisspelled](foundation/nsattributedstring/key/accessibilitymisspelled.md)
- [accessibilityShadow](foundation/nsattributedstring/key/accessibilityshadow.md)
- [accessibilitySpeechAnnouncementPriority](foundation/nsattributedstring/key/accessibilityspeechannouncementpriority.md)
- [accessibilitySpeechIPANotation](foundation/nsattributedstring/key/accessibilityspeechipanotation.md)
- [accessibilitySpeechLanguage](foundation/nsattributedstring/key/accessibilityspeechlanguage.md)
- [accessibilitySpeechPitch](foundation/nsattributedstring/key/accessibilityspeechpitch.md)
- [accessibilitySpeechPunctuation](foundation/nsattributedstring/key/accessibilityspeechpunctuation.md)
- [accessibilitySpeechQueueAnnouncement](foundation/nsattributedstring/key/accessibilityspeechqueueannouncement.md)
- [accessibilitySpeechSpellOut](foundation/nsattributedstring/key/accessibilityspeechspellout.md)
- [accessibilityTextCustom](foundation/nsattributedstring/key/accessibilitytextcustom.md)
- [accessibilityTextHeadingLevel](foundation/nsattributedstring/key/accessibilitytextheadinglevel.md)
- [accessibilityStrikethrough](foundation/nsattributedstring/key/accessibilitystrikethrough.md)
- [accessibilityStrikethroughColor](foundation/nsattributedstring/key/accessibilitystrikethroughcolor.md)
- [accessibilitySuperscript](foundation/nsattributedstring/key/accessibilitysuperscript.md)
- [accessibilityUnderline](foundation/nsattributedstring/key/accessibilityunderline.md)
- [accessibilityUnderlineColor](foundation/nsattributedstring/key/accessibilityunderlinecolor.md)
- [UIAccessibilityTextAttributeContext](foundation/nsattributedstring/key/uiaccessibilitytextattributecontext.md)

### Getting Markdown attribute keys

- [inlinePresentationIntent](foundation/nsattributedstring/key/inlinepresentationintent.md)
- [presentationIntentAttributeName](foundation/nsattributedstring/key/presentationintentattributename.md)
- [markdownSourcePosition](foundation/nsattributedstring/key/markdownsourceposition.md)
- [alternateDescription](foundation/nsattributedstring/key/alternatedescription.md)
- [imageURL](foundation/nsattributedstring/key/imageurl.md)

### Getting translation-related attribute keys

- [languageIdentifier](foundation/nsattributedstring/key/languageidentifier.md)
- [morphology](foundation/nsattributedstring/key/morphology.md)
- [inflectionRule](foundation/nsattributedstring/key/inflectionrule.md)
- [inflectionAlternative](foundation/nsattributedstring/key/inflectionalternative.md)
- [agreeWithArgument](foundation/nsattributedstring/key/agreewithargument.md)
- [agreeWithConcept](foundation/nsattributedstring/key/agreewithconcept.md)
- [referentConcept](foundation/nsattributedstring/key/referentconcept.md)
- [localizedNumberFormat](foundation/nsattributedstring/key/localizednumberformat.md)

### Getting formatting attribute keys

- [listItemDelimiter](foundation/nsattributedstring/key/listitemdelimiter.md)

### Deprecated Keys

- [expansion](foundation/nsattributedstring/key/expansion.md)
- [obliqueness](foundation/nsattributedstring/key/obliqueness.md)
- [verticalGlyphForm](foundation/nsattributedstring/key/verticalglyphform.md)
- [characterShapeAttributeName](foundation/nsattributedstring/key/charactershapeattributename.md)
- [usesScreenFontsDocumentAttribute](foundation/nsattributedstring/key/usesscreenfontsdocumentattribute.md)

### Initializers

- [init(_:)](foundation/nsattributedstring/key/init(_:).md)
- [init(rawValue:)](foundation/nsattributedstring/key/init(rawvalue:).md)

### Type Properties

- [writingToolsExclusionAttributeName](foundation/nsattributedstring/key/writingtoolsexclusion.md)

## Relationships

### Conforms To

- [Equatable](swift/equatable.md)
- [Hashable](swift/hashable.md)
- [RawRepresentable](swift/rawrepresentable.md)
- [Sendable](swift/sendable.md)
- [SendableMetatype](swift/sendablemetatype.md)

## See Also

### Getting text content attributes

- [NSAttributedString.TextHighlightStyle](foundation/nsattributedstring/texthighlightstyle.md)
- [NSAttributedString.TextHighlightColorScheme](foundation/nsattributedstring/texthighlightcolorscheme.md)
- [NSAttributedString.TextEffectStyle](foundation/nsattributedstring/texteffectstyle.md)
- [NSAttributedString.SpellingState](foundation/nsattributedstring/spellingstate.md)
- [NSUnderlineStyle](uikit/nsunderlinestyle.md)
- [NSWritingDirectionFormatType](uikit/nswritingdirectionformattype.md)
