HTTP Headers
Width
Deprecated: This feature is no longer recommended for use. Although some browsers may still support it, it could have been removed from the official web standards, might be in the process of being deprecated, or kept solely for backward compatibility. Developers should avoid using this feature and update existing code accordingly. For guidance, refer to the compatibility table provided at the bottom of this document. Be aware that this feature might stop functioning at any time.
Secure context: This feature is only accessible within secure contexts such as HTTPS, and availability may depend on whether the browser supports this feature.
Non-standard: This feature does not conform to official standards and is not part of any standards track. It is not recommended for deployment on production websites because it may not work consistently across browsers. There could also be significant differences in implementation, and future updates might alter its behavior.
Warning:
The Width
header has been removed from the client hints specification as per draft-ietf-httpbis-client-hints-07. The suggested replacement is Sec-CH-Width
, which refers to Responsive Image Client Hints.
The HTTP Width
request header is a device client hint indicating the desired width of a resource in physical pixels — typically the intrinsic size of an image. The value specified is rounded up to the nearest integer (ceiling value).
This hint allows clients to request a resource optimized for both the device’s screen and the layout, considering the density-corrected screen width and the image’s extrinsic size within the page layout.
If the desired resource width is unknown at request time or the resource lacks a display width, the Width
header can be omitted.
If the Width
header appears multiple times in a message, the last occurrence will be used.
Width
request header:Header type | Request header, Client hint |
---|---|
Forbidden request header | No |
Syntax
Width: <number>
Directives
The width of the resource in physical pixels, rounded up to the nearest whole number.
Example
The server must first opt in to receive the Width
header by including the Accept-CH response header with the value Width
.
For example:
Accept-CH: Width
Subsequently, on later requests, the client can send the Width
header with its value:
Width: 1920
How to Modify Header using Requestly
Requestly is a powerful Chrome extension that allows you to modify HTTP headers, including the Width header. This is helpful when you want to simulate different screen widths or device dimensions during development or testing. Steps to Modify the Width Header:
- Install and open the Requestly Chrome extension. You can find it on the Chrome Web Store.
- Create a new rule: Click on “Create Rule” and choose “Modify Headers” from the list of available rule types.
- Add a new header modification:
- Under “Action”, select “Add” or “Override”.
- In the “Header Name” field, enter Width.
- In the “Header Value” field, enter the desired width value (e.g., 1024).
- Set the URL condition: Specify the URL or pattern where this header change should apply (e.g., https://your-api.com/*).
- Save the rule.
Once set up, Requestly will inject the Width header into all matching requests, allowing you to test how your server or application reacts to different screen width values. Modifying the Width header can help test how websites or services respond to various device screen sizes without needing physical devices or emulator changes.
Table of Contents
- No headings found.