document.documentElement.clientWidth; /* 1200 */
window.innerWidth; /* 1200 */
window.outerWidth; /* 1200 */Viewport concepts / notebook
Viewport concepts
Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.
document.documentElement.clientHeight; /* 800 */
window.innerHeight; /* 800 */
window.outerHeight; /* 900 */document.documentElement.clientWidth; /* 800 */
window.innerWidth; /* 800 */
window.outerWidth; /* 800 in Firefox, 1200 in chrome */document.documentElement.clientHeight; /* 533 */
window.innerHeight; /* 533 */
window.outerHeight; /* 596 in Firefox, 900 in chrome */body > header {
position: fixed;
top: 0;
}
body > footer {
position: fixed;
bottom: 0;
}iframe {
width: 50vw;
}@media screen and (width <= 500px) {
p {
color: red;
}
}<svg height="300" width="400"></svg>@media screen and (400px <= width <= 500px) {
/* CSS goes here */
}<meta name="viewport" content="width=device-width" />