Menu
×
   ❮     
HTML CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C C++ C# BOOTSTRAP REACT MYSQL JQUERY EXCEL XML DJANGO NUMPY PANDAS NODEJS R TYPESCRIPT ANGULAR GIT POSTGRESQL MONGODB ASP AI GO KOTLIN SASS VUE DSA GEN AI SCIPY AWS CYBERSECURITY DATA SCIENCE
     ❯   

HTML height 属性


定义和用法

The height 属性以像素为单位指定元素的高度。


适用于

The height 属性可用于以下元素

元素 属性
<canvas> 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">
亲自试一试 »

嵌入示例

一个高度和宽度为 200 像素的 flash 动画

<embed src="helloworld.swf" width="200" height="200">
亲自试一试 »

Iframe 示例

一个指定高度和宽度为 200 像素的 <iframe>

<iframe src="/default.asp" width="200" height="200">
</iframe>
亲自试一试 »

Img 示例

一个高度和宽度为 42 像素的图像

<img src="smiley.gif" alt="笑脸" height="42" width="42">
亲自试一试 »

输入示例

定义一个图像作为提交按钮,带有 height 和 width 属性

<form action="/action_page.php">
  姓氏:<input type="text" name="fname"><br>
  姓氏:<input type="text" name="lname"><br>
  <input type="image" src="img_submit.gif" alt="提交" width="48" height="48">
</form>
亲自试一试 »

对象示例

一个高度和宽度为 400 像素的 flash 动画:

<object data="helloworld.swf" height="400" width="400"></object>
亲自试一试 »

视频示例

一个指定高度和宽度的视频播放器

<video width="320" height="240" controls>
  <source src="movie.mp4" type="video/mp4">
  <source src="movie.ogg" type="video/ogg">
  您的浏览器不支持 video 标签。
</video>
亲自试一试 »

浏览器支持

The height 属性对每个元素具有以下浏览器支持

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

×

Contact Sales

If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail:
[email protected]

Report Error

If you want to report an error, or if you want to make a suggestion, send us an e-mail:
[email protected]

W3Schools is optimized for learning and training. Examples might be simplified to improve reading and learning. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. While using W3Schools, you agree to have read and accepted our terms of use, cookie and privacy policy.

Copyright 1999-2024 by Refsnes Data. All Rights Reserved. W3Schools is Powered by W3.CSS.