---
title: "port(_:)"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/url/formatstyle/port(_:)"
---

# port(_:)

Modifies a format style to display a URL’s port component in accordance with the provided option.

## Declaration

```swift
func port(_ strategy: URL.FormatStyle.ComponentDisplayOption = .omitIfHTTPFamily) -> URL.FormatStyle
```

## Parameters

- `strategy`: A component display option that indicates when, if ever, to display the port component.

## Return Value

Return Value A modified URL.FormatStyle that incorporates the specified behavior.

## See Also

### Customizing style behavior

- [scheme(_:)](foundation/url/formatstyle/scheme(_:).md)
- [user(_:)](foundation/url/formatstyle/user(_:).md)
- [password(_:)](foundation/url/formatstyle/password(_:).md)
- [host(_:)](foundation/url/formatstyle/host(_:).md)
- [URL.FormatStyle.HostDisplayOption](foundation/url/formatstyle/hostdisplayoption.md)
- [path(_:)](foundation/url/formatstyle/path(_:).md)
- [query(_:)](foundation/url/formatstyle/query(_:).md)
- [fragment(_:)](foundation/url/formatstyle/fragment(_:).md)
- [URL.FormatStyle.ComponentDisplayOption](foundation/url/formatstyle/componentdisplayoption.md)
