diff --git a/files/en-us/web/manifest/orientation/index.md b/files/en-us/web/manifest/orientation/index.md index 9c1b47059bad85a..b1837ec21efa787 100644 --- a/files/en-us/web/manifest/orientation/index.md +++ b/files/en-us/web/manifest/orientation/index.md @@ -7,30 +7,306 @@ browser-compat: html.manifest.orientation {{QuickLinksWithSubpages("/en-US/docs/Web/Manifest")}} -The `orientation` member defines the default orientation for all the website's top-level {{Glossary("Browsing context", "browsing contexts")}}. - -> **Note:** `orientation` and/or its specific values might not be supported by a user agent on various display modes because supporting them does not make sense for the particular context. +The `orientation` manifest member is used to specify the default orientation for your web application. +It defines how the app should be displayed when launched and during use, in relation to the device's screen orientation, particularly on devices that support multiple orientations. > [!NOTE] -> The orientation can be changed at runtime via the [Screen Orientation API](/en-US/docs/Web/API/Screen_Orientation_API). +> The app's orientation can be changed during runtime through various means, such as using the [Screen Orientation API](/en-US/docs/Web/API/Screen_Orientation_API). + +## Syntax + +```json-nolint +/* Keyword values */ +"orientation": "any" +"orientation": "natural" +"orientation": "portrait" +"orientation": "portrait-primary" +"orientation": "portrait-secondary" +"orientation": "landscape" +"orientation": "landscape-primary" +"orientation": "landscape-secondary" +``` ### Values -`orientation` can take one of the following values: +- `orientation` + + - : A string that specifies the default orientation for the web app. + If the `orientation` member is not specified or an invalid value is provided, the web app will typically use the device's natural orientation and any user or system-level orientation settings. + + The `orientation` value must be one of the following keywords: + + - `any` + + - : Displays the web app in any orientation allowed by the device's operating system or user settings. + It allows the app to rotate freely to match the orientation of the device when it is rotated. + + - `natural` + + - : Displays the web app in the orientation considered most natural for the device, as determined by the browser, operating system, user settings, or the screen itself. It corresponds to how the device is most commonly held or used: + + - On devices typically held vertically, such as mobile phones, `natural` is usually `portrait-primary`. + - On devices typically used horizontally, such as computer monitors and tablets, `natural` is usually `landscape-primary`. + + When the device is rotated, the app may or may not rotate so as to match the device's natural orientation; this behavior may vary depending on the specific device, browser implementation, and user settings. + + - `portrait` + + - : Displays the web app with height greater than width. + It allows the app to switch between `portrait-primary` and `portrait-secondary` orientations when the device is rotated. + + - `portrait-primary` + + - : Displays the web app in portrait mode, typically with the device held upright. + This is usually the default app orientation on devices that are naturally portrait. + Depending on the device and browser implementation, the app will typically maintain this orientation even when the device is rotated. + + - `portrait-secondary` + + - : Displays the web app in inverted portrait mode, which is `portrait-primary` rotated 180 degrees. + Depending on the device and browser implementation, the app will typically maintain this orientation even when the device is rotated. + + - `landscape` + + - : Displays the web app with width greater than height. + It allows the app to switch between `landscape-primary` and `landscape-secondary` orientations when the device is rotated. + + - `landscape-primary` + + - : Displays the web app in landscape mode, typically with the device held in its standard horizontal position. + This is usually the default app orientation on devices that are naturally landscape. + Depending on the device and browser implementation, the app will typically maintain this orientation even when the device is rotated. + + - `landscape-secondary` + + - : Displays the web app in inverted landscape mode, which is `landscape-primary` rotated 180 degrees. + Depending on the device and browser implementation, the app will typically maintain this orientation even when the device is rotated. + +## Description + +To understand the `orientation` manifest member, it's important to be familiar with the following orientation-related concepts: + +- **Device orientation**: Defines how the device is physically held or positioned. +- **Screen orientation**: Defines the physical orientation of the device's display. +- **App orientation**: Defines how the app's content is displayed relative to the screen orientation. + +When a device is rotated, it typically changes the screen orientation. For example, rotating a mobile phone from vertical to horizontal usually switches the screen from portrait to landscape mode. Without any specific orientation set in the manifest, most apps will adjust their layout to fit this new screen orientation. + +The manifest's `orientation` member allows you to control how your app responds to these changes. By specifying a preferred orientation for your app, you can decide whether your app should adapt to screen orientation changes or maintain a fixed layout regardless of how the device is held. For example, by setting `"orientation": "portrait-primary"`, you can indicate that you prefer your app to always be displayed in upright portrait mode relative to the screen, even if the device is rotated. The browser or operating system will attempt to honor this preference when possible. + +The example below illustrates how a web app's layout might appear when a mobile phone is rotated. For this example, assume that the app's `orientation` value is set to `any`, allowing the app to rotate between all `orientation` values when the mobile phone is rotated. Also assume that both the phone and the browser support all orientations. The sequence shows a clockwise rotation of the phone, with each position rotated from the starting position as follows: + +- Top-left: `portrait-primary` (starting position) +- Top-right: `landscape-primary` (90 degrees) +- Bottom-left: `portrait-secondary` (180 degrees) +- Bottom-right: `landscape-secondary` (270 degrees) + +```html hidden +
portrait-primary
landscape-primary
portrait-secondary
landscape-secondary