HTML and CSS for full screen mode
Besides using the Fullscreen API, you also need to use some HTML and CSS code to make your web page look good and function well in full screen mode. For example, you may want to use the <meta> tag to set the viewport width and height to match the device screen size, and use the <link> tag to specify a different stylesheet for full screen mode. For example, you can use this code in the <head> section of your HTML document:
<meta name="viewport" content="width=device-width, height=device-height, initial-scale=1.0">
<link rel="stylesheet" href="style.css">
<link rel="stylesheet" href="fullscreen.css" media="fullscreen">
The media attribute of the <link> tag allows you to apply a different stylesheet only when the web page is in full screen mode. In the fullscreen.css file, you can use the :fullscreen pseudo-class selector to target the element that is in full screen mode, and apply some styles to it. For example, you can use this code to make the video element fill the entire screen and hide the controls in full screen mode:
video:fullscreen {
width: 100%;
height: 100%;
object-fit: cover;
controls: none;
}
You can also use media queries to adjust the layout and design of your web page for different screen sizes and orientations in full screen mode. For example, you can use this code to change the font size and color of a heading element depending on the screen width and orientation in full screen mode:
@media (min-width: 768px) and (orientation: landscape) and (fullscreen) {
h1 {
font-size: 3rem;
color: white;
}
}
By using the Fullscreen API and some basic HTML and CSS code, you can enable full screen mode for web pages in HTML5 and create a more immersive and engaging experience for your users. You can also use other HTML5 features, such as the video and audio elements, the canvas element, or the Web Audio API, to enhance your multimedia content in full screen mode.