HTML height 属性

前へ 全ての HTML 属性 次へ

定義と用法

height 属性は、要素の高さをピクセルで指定します。


適用

height 属性は、以下の要素で使用することができます:

要素 属性
<height> height
<embed> height
<iframe> height
<img> height
<input> height
<object> height
<video> height

Canvas の例

幅と高さが 200 ピクセルの <canvas> 要素:

<canvas id="myCanvas" width="200" height="200" style="border:1px solid">
Try it Yourself ❯

Embed の例

幅と高さが 200 ピクセルの フラッシュ・アニメーション:

<embed src="helloworld.swf" width="200" height="200">
Try it Yourself ❯

Iframe の例

幅と高さが 200 ピクセルの <iframe>:

<iframe src="/default.html" width="200" height="200">
</iframe>
Try it Yourself ❯

Img の例

幅と高さが 42 ピクセルの画像:

<img src="smiley.gif" alt="Smiley face" height="42" width="42">
Try it Yourself ❯

Input の例

height と width 属性を持つ、送信ボタンとしての画像を定義します:

<form action="demo_form.html">
  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>
Try it Yourself ❯

Object の例

幅と高さが 400 ピクセルの フラッシュ・アニメーション:

<object data="helloworld.swf" height="400" width="400"></object>
Try it Yourself ❯

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>
Try it Yourself ❯

ブラウザ・サポート

height 属性は、要素ごとに以下のブラウザがサポートしています。

要素
canvas 4.0 9.0 2.0 3.1 9.0
embed Yes Yes Yes Yes Yes
iframe Yes Yes Yes Yes Yes
img Yes Yes Yes Yes Yes
input 1.0 Yes 16.0 Yes 1.0
object Yes Yes Yes Yes Yes
video Yes Yes Yes Yes Yes

前へ 全ての HTML 属性 次へ