Sec-CH-Width header

Secure context: This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.

The HTTP Sec-CH-Width request header is a device client hint which indicates the desired resource width in physical pixels — the intrinsic size of an image. The provided pixel value is a number rounded to the smallest following integer (i.e., ceiling value).

The hint is only sent on image requests.

The hint allows the client to request a resource that is optimal for both the screen and the layout: taking into account both the density-corrected width of the screen and the image's extrinsic size within the layout.

If the desired resource width is not known at the time of the request or the resource does not have a display width, the Sec-CH-Width header field can be omitted. If the Sec-CH-Width header appears more than once in a message the last occurrence is used.

Header type Request header, Client hint
Forbidden request header No

Syntax

http
Width: <number>

Directives

<number>

The width of the resource in physical pixels, rounded up to the nearest integer.

Examples

The server first needs to opt in to receive the Sec-CH-Width header by sending the response headers Accept-CH containing Sec-CH-Width.

http
Accept-CH: Sec-CH-Width

Then on subsequent image requests the client might send Sec-CH-Width header back:

http
Width: 1920

Browser compatibility

See also