CKTIS / HTML
HTML element: canvas
The canvas element provides a scriptable bitmap for dynamic drawing, but pixels alone do not create document semantics.
Version: WHATWG HTML Living Standard; index snapshot date recorded separately
Syntax
<canvas width="4" height="2">accessible fallback</canvas>The width and height attributes of canvas set its internal coordinate space, defaulting to 300 × 150; CSS dimensions only scale the bitmap, so crisp HiDPI output requires deliberate devicePixelRatio handling.
Child content of canvas is fallback content and should provide equivalent information or functionality, because a drawn chart, label, or control does not become accessible automatically.
getContext("2d") returns a CanvasRenderingContext2D, and another request for the same kind returns the same object. Assigning width or height clears the bitmap and resets context state.
The example draws two colors and reads the first pixel with getImageData(); cross-origin images without CORS can remove origin-clean status and cause SecurityError, including from toDataURL().
Examples
<!doctype html>
<meta charset="utf-8">
<canvas id="chart" width="4" height="2">Two red units and two blue units.</canvas>
<output id="result"></output>
<script>
const chart = document.querySelector("#chart");
const context = chart.getContext("2d");
context.fillStyle = "rgb(255, 0, 0)";
context.fillRect(0, 0, 2, 2);
context.fillStyle = "rgb(0, 0, 255)";
context.fillRect(2, 0, 2, 2);
const pixel = [...context.getImageData(0, 0, 1, 1).data].join(",");
document.querySelector("#result").textContent = `size=${chart.width}x${chart.height}; pixel=${pixel}; sameContext=${chart.getContext("2d") === context}; fallback=${chart.textContent.trim()}`;
</script>
Result
size=4x2; pixel=255,0,0,255; sameContext=true; fallback=Two red units and two blue units.
The result verifies dimensions, an RGBA pixel, context reuse, and fallback text; it does not assess visual quality or complete chart accessibility.