Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / CSS

CSS property `overflow`

`overflow` specifies on both axes handling of content extending beyond the padding box.

Version: CSS modules; captured CSSWG editor index includes draft and obsolete features requiring review

Syntax

[ visible | hidden | clip | scroll | auto ]{1,2}

overflow specifies on both axes handling of content extending beyond the padding box.

The example creates a real 80×40 px scroll container with 200×100 px content and reports clientWidth/clientHeight and scrollWidth/scrollHeight.

Grammar: [ visible | hidden | clip | scroll | auto ]{1,2}. This example does not replace wheel and touch testing on the target device.

visible does not create a scrollport, clip forbids programmatic scrolling, while auto and scroll can establish a new block formatting context.

Examples

<!doctype html>
<html lang="en"><meta charset="utf-8"><title>CKTIS CSS reference example</title><body><pre id="result"></pre><script>
const x=document.createElement("div"),c=document.createElement("div");document.body.prepend(x);x.append(c);x.style.cssText="width:80px;height:40px;overflow:auto";c.style.cssText="width:200px;height:100px";const s=getComputedStyle(x);document.querySelector("#result").textContent="client="+x.clientWidth+"x"+x.clientHeight+"; scroll="+x.scrollWidth+"x"+x.scrollHeight+"; computed="+s.getPropertyValue("overflow").trim();
</script></body></html>

Result

client=65x25; scroll=200x100; computed=auto

The example was executed locally in an isolated, network-free Chrome session; the result comes from the browser CSS API.

Sources