CSS @media display-mode Property

You are Here:

CSS @media display-mode

CSS @media display-mode can be used to test the display mode of an application.

Example

HTML Online Editor
<!DOCTYPE html> <html lang="en-US"> <head> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <style> @media (display-mode: fullscreen) { h1 { color: green; } } @media (display-mode: standalone) { h1 { color: red; } } @media (display-mode: minimal-ui) { h1 { color: orange; } } @media (display-mode: browser) { h1 { color: blue; } } </style> </head> <body> <h1>CSS @media display-mode</h1> <p>Open this example in firefox and press F11 for fullscreen.</p> </body> </html>

Syntax

Using CSS

@media (display-mode: fullscreen){ element{ color: red; } }

Using Javascript

elementelegram.dogdia = "(display-mode: fullscreen)";

Media Query Value

The following table provides the list of media query value for display-mode.

ValueExplanationFallback
fullscreenSpecifies that the page/application is opened in fullscreen.standalone
standaloneSpecifies that the page/application is a standalone.minimal-ui
minimal-uiSpecifies that the page/application is a standalone, but will have a minimal set of UI elements for controlling navigation.browser
browserSpecifies that the page/application is opened in a browser but not in fullscreen.(none)

Using JavaScript

In the following example, we will demonstrate how to set the CSS @media display-mode media feature by using javascript.

Example

HTML Online Editor
<!DOCTYPE html> <html lang="en-US"> <head> <meta name="viewport" content="width=device-width, initial-scale=1.0"> </head> <body> <h1>CSS @media display-mode</h1> <button onclick="myFunction()">Click Me</button> <script> function myFunction(){ var styles = 'h1{ color:blue;}'; var styleSheet = document.createElement("style"); styleSheet.type = "text/css"; styleSheet.media = "(display-mode: browser)"; styleSheet.innerText = styles; document.head.appendChild(styleSheet); } </script> </body> </html>

Reminder

Hi Developers, we almost covered 98.7% of CSS Tutorials with examples for quick and easy learning.

We are working to cover every Single Concept in CSS.

Please do google search for:

Join Our Channel

Join our telegram channel to get an instant update on depreciation and new features on HTML, CSS, JavaScript, jQuery, Node.js, PHP and Python.

This channel is primarily useful for Full Stack Web Developer.

Share this Page

Meet the Author