---
title: fragment
framework: foundation
role: symbol
role_heading: Instance Property
path: foundation/urlcomponents/fragment
---

# fragment

The fragment subcomponent.

## Declaration

```swift
var fragment: String? { get set }
```

## Discussion

Discussion The getter for this property removes any percent encoding this component may have (if the component allows percent encoding). Setting this property assumes the subcomponent or component string is not percent encoded and will add percent encoding (if the component allows percent encoding).

## See Also

### Accessing components in native format

- [host](foundation/urlcomponents/host.md)
- [encodedHost](foundation/urlcomponents/encodedhost.md)
- [password](foundation/urlcomponents/password.md)
- [path](foundation/urlcomponents/path.md)
- [port](foundation/urlcomponents/port.md)
- [query](foundation/urlcomponents/query.md)
- [queryItems](foundation/urlcomponents/queryitems.md)
- [scheme](foundation/urlcomponents/scheme.md)
- [user](foundation/urlcomponents/user.md)
