最新的Web開發教程
 

HTML height Attribute


定義和用法

height屬性指定元素的高度,以像素為單位。


適用於

height屬性可以在下列元素一起使用:

分子 屬性
<height> height
<embed> height
<iframe> height
<img> height
<input> height
<object> height
<video> height

例子

Canvas

一個<canvas> ,其高度為200個像素寬度的元素:

<canvas id="myCanvas" width="200" height="200" style="border:1px solid">
試一試»

Embed

一個Flash動畫,其高度為200個像素寬度:

<embed src="helloworld.swf" width="200" height="200">
試一試»

Iframe示例

一個<iframe>用指定的高度和200像素寬:

<iframe src="/default.html" width="200" height="200">
</iframe>
試一試»

Img示例

用的42個像素的高度和寬度的圖像:

<img src="smiley.gif" alt="Smiley face" height="42" width="42">
試一試»

Input示例

定義圖片作為提交按鈕,用heightwidth屬性:

<form action="demo_form.asp">
  First name: <input type="text" name="fname"><br>
  Last name: <input type="text" name="lname"><br>
  <input type="image" src="img_submit.gif" alt="Submit" width="48" height="48">
</form>
試一試»

Object實例

Flash動畫具有400像素的高度和寬度::

<object data="helloworld.swf" height="400" width="400"></object>
試一試»

Video示例

視頻播放器指定的高度和寬度:

<video width="320" height="240" controls>
  <source src="movie.mp4" type="video/mp4">
  <source src="movie.ogg" type="video/ogg">
  Your browser does not support the video tag.
</video>
試一試»

瀏覽器支持

height屬性為每個元素以下瀏覽器支持:

元件
canvas 4 9 2.0 3.1 9
embed
iframe
img
input 1.0 16.0 1.0
object
video