Movatterモバイル変換


[0]ホーム

URL:


  1. Web
  2. HTTP
  3. Reference
  4. Headers
  5. Sec-CH-Viewport-Width

Sec-CH-Viewport-Width header

Secure context: This feature is available only insecure contexts (HTTPS), in some or allsupporting browsers.

Experimental:This is anexperimental technology
Check theBrowser compatibility table carefully before using this in production.

The HTTPSec-CH-Viewport-Widthrequest header is adevice client hint which provides the client's layout viewport width inCSS pixels.The value is rounded up to the smallest following integer (i.e., ceiling value).

The hint can be used with other screen-specific hints to deliver images optimized for a specific screen size, or to omit resources that are not needed for a particular screen width.If theSec-CH-Viewport-Width header appears more than once in a message the last occurrence is used.

A server has to opt-in to receive theSec-CH-Viewport-Width header from the client, by sending theAccept-CH response header.Servers that opt-in will typically also specify it in theVary header which informs caches that the server may send different responses based on the header value in a request.

Header typeRequest header,Client hint
Forbidden request headerNo

Syntax

http
Sec-CH-Viewport-Width: <number>

Directives

<number>

The width of the user's viewport inCSS pixels, rounded up to the nearest integer.

Examples

Using Sec-CH-Viewport-Width

A server must first opt-in to receive theSec-CH-Viewport-Width header by sending the response headerAccept-CH containing the directiveSec-CH-Viewport-Width.

http
Accept-CH: Sec-CH-Viewport-Width

In subsequent requests, the client might sendSec-CH-Viewport-Width header:

http
Sec-CH-Viewport-Width: 320

Specifications

Specification
Responsive Image Client Hints
# sec-ch-viewport-width

Browser compatibility

See also

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2026 Movatter.jp