--- title: HTMLCanvasElement.height slug: Web/API/HTMLCanvasElement/height translation_of: Web/API/HTMLCanvasElement/height ---
HTMLCanvasElement.height
wyrażana jest w dodatniej liczbie całkowitej
odpowiada za atrybut height
elemetu HTML <canvas>
i jest interpretowany w pikselach CSS. Jeśli atrybut nie został określony, lub została przypisana do niego nieprawidłowa wartość, np. negatywna, zostanie użyta domyślna wartość 150
.var pxl = canvas.height; canvas.height = pxl;
Biorąc pod uwagę element {{HTMLElement("canvas")}}:
<canvas id="canvas" width="300" height="300"></canvas>
Można sprawdzić jego wysokość za pomocą kodu:
var canvas = document.getElementById('canvas'); console.log(canvas.height); // 300
Specification | Status | Comment |
---|---|---|
{{SpecName('HTML WHATWG', "scripting.html#attr-canvas-height", "HTMLCanvasElement.height")}} | {{Spec2('HTML WHATWG')}} |
Brak zmian od ostatniego snapshota, {{SpecName('HTML5 W3C')}} |
{{SpecName('HTML5.1', "scripting-1.html#attr-canvas-height", "HTMLCanvasElement.height")}} | {{Spec2('HTML5.1')}} | |
{{SpecName('HTML5 W3C', "scripting-1.html#attr-canvas-height", "HTMLCanvasElement.height")}} | {{Spec2('HTML5 W3C')}} | Snapshot {{SpecName('HTML WHATWG')}} zawierający początkową definicje. |
{{Compat("api.HTMLCanvasElement.height")}}