DOM Interfaces
HTMLCanvasElement
Represents a drawable bitmap surface with context creation and image export methods. Changing width or height resets its drawing buffer and rendering state. CSS size is a separate concern; supply accessible alternatives. Example result: 40.
Formal Syntax & Structure
html syntaxhtml
const element = document.getElementById('demo'); // HTMLCanvasElementReturn Value
HTMLCanvasElement
An existing HTML DOM object associated with the canvas element in this example; this interface is a type, not a function return contract.
Working Example
Example Snippethtml
<canvas id="demo" width="40" height="30">Canvas fallback</canvas><p> Result: <output id="result"></output></p><script> const e = document.getElementById('demo'); const result = value => { document.getElementById("result").textContent = String(value); }; result(e.width);</script>