🔸document size
🔰 JS ⟩ browser ⟩ DOM ⟩ types ⟩ Document ⟩ size
document size
- width: - document.documentElement.offsetWidth
- height: - document.documentElement.offsetHeight
.offsetWidth, .offsetHeight will round the value to an integer. If you need a fractional value, use elem.getBoundingClientRect().
- .clientWidth/.clientHeight = content + padding 
- .offsetWidth/.offsetHeight = contnet + padding + border 
- .scrollWidth/.scrollHeight = content + padding + overflow 
// document size
const doc = {
    get width() { return document.documentElement.offsetWidth },
    get height() { return document.documentElement.offsetHeight },
};- Document ⟩ .documentElement (the <html> element) 
Last updated
Was this helpful?