deoHeight - Web APIs - MDN Web Docs
Có thể bạn quan tâm
- Skip to main content
- Skip to search
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
- Learn more
- See full compatibility
- Report feedback
The HTMLVideoElement interface's read-only videoHeight property indicates the intrinsic height of the video, expressed in CSS pixels. In simple terms, this is the height of the media in its natural size.
In this article
- Value
- Examples
- Specifications
- Browser compatibility
Value
An integer value specifying the intrinsic height of the video in CSS pixels. If the element's readyState is HTMLMediaElement.HAVE_NOTHING, then the value of this property is 0, because neither video nor poster frame size information is yet available.
About intrinsic width and height
A user agent calculates the intrinsic width and height of the element's media by starting with the media's raw pixel width and height, then taking into account factors including:
- The media's aspect ratio.
- The media's clean aperture (the sub-rectangle centered within the media that matches the target aspect ratio).
- The target device's resolution.
- Any other factors required by the media format.
If the element is currently displaying the poster frame rather than rendered video, the poster frame's intrinsic size is considered to be the size of the <video> element.
If at any time the intrinsic size of the media changes and the element's readyState isn't HAVE_NOTHING, a resize event will be sent to the <video> element. This can happen when the element switches from displaying the poster frame to displaying video content, or when the displayed video track changes.
Examples
This example creates a handler for the resize event that resizes the <video> element to match the intrinsic size of its contents.
jslet v = document.getElementById("myVideo"); v.addEventListener("resize", (ev) => { let w = v.videoWidth; let h = v.videoHeight; if (w && h) { v.style.width = w; v.style.height = h; } });Note that this only applies the change if both the videoWidth and the videoHeight are non-zero. This avoids applying invalid changes when there's no true information available yet for dimensions.
Specifications
| Specification |
|---|
| HTML# dom-video-videoheight-dev |
Browser compatibility
Help improve MDN
Was this page helpful to you? Yes No Learn how to contributeThis page was last modified on Sep 18, 2025 by MDN contributors.
View this page on GitHub • Report a problem with this content Filter sidebar- The HTML DOM API
- HTMLVideoElement
- Instance properties
- disablePictureInPicture
- height
- poster
- videoHeight
- videoWidth
- width
- Instance methods
- cancelVideoFrameCallback()
- getVideoPlaybackQuality()
- requestPictureInPicture()
- requestVideoFrameCallback()
- Events
- enterpictureinpicture
- leavepictureinpicture
- resize
- Inheritance
- HTMLMediaElement
- HTMLElement
- Element
- Node
- EventTarget
- Related pages for HTML DOM
- BeforeUnloadEvent
- DOMStringMap
- ErrorEvent
- HTMLAnchorElement
- HTMLAreaElement
- HTMLAudioElement
- HTMLBRElement
- HTMLBaseElement
- HTMLBodyElement
- HTMLButtonElement
- HTMLCanvasElement
- HTMLDListElement
- HTMLDataElement
- HTMLDataListElement
- HTMLDialogElement
- HTMLDivElement
- HTMLDocument
- HTMLElement
- HTMLEmbedElement
- HTMLFieldSetElement
- HTMLFormControlsCollection
- HTMLFormElement
- HTMLFrameSetElement Deprecated
- HTMLHRElement
- HTMLHeadElement
- HTMLHeadingElement
- HTMLHtmlElement
- HTMLIFrameElement
- HTMLImageElement
- HTMLInputElement
- HTMLLIElement
- HTMLLabelElement
- HTMLLegendElement
- HTMLLinkElement
- HTMLMapElement
- HTMLMediaElement
- HTMLMenuElement
- HTMLMetaElement
- HTMLMeterElement
- HTMLModElement
- HTMLOListElement
- HTMLObjectElement
- HTMLOptGroupElement
- HTMLOptionElement
- HTMLOptionsCollection
- HTMLOutputElement
- HTMLParagraphElement
- HTMLPictureElement
- HTMLPreElement
- HTMLProgressElement
- HTMLQuoteElement
- HTMLScriptElement
- HTMLSelectElement
- HTMLSourceElement
- HTMLSpanElement
- HTMLStyleElement
- HTMLTableCaptionElement
- HTMLTableCellElement
- HTMLTableColElement
- HTMLTableElement
- HTMLTableRowElement
- HTMLTableSectionElement
- HTMLTemplateElement
- HTMLTextAreaElement
- HTMLTimeElement
- HTMLTitleElement
- HTMLTrackElement
- HTMLUListElement
- HTMLUnknownElement
- HashChangeEvent
- History
- ImageData
- Location
- MessageChannel
- MessageEvent
- MessagePort
- Navigator
- PageRevealEvent
- PageSwapEvent
- PageTransitionEvent
- Plugin Deprecated
- PluginArray Deprecated
- PromiseRejectionEvent
- RadioNodeList
- TimeRanges
- UserActivation
- ValidityState
- Window
- WorkletGlobalScope
- Guides
- Using microtasks in JavaScript with queueMicrotask()
- In depth: Microtasks and the JavaScript runtime environment
Từ khóa » Html5 Video Stretch Aspect Ratio
-
HTML 5 Video Stretch - Stack Overflow
-
HTML5-video-stretch-fullscreen.css - Gists · GitHub
-
Fluid Width Video | CSS-Tricks
-
Html5 Video Stretch? [SOLVED] - DaniWeb
-
HTML 5 Video Stretch - Newbedev
-
HTML 5 Video Stretch - Anycodings
-
How To Make Html5 Video Responsive? - Digi Effects
-
CSS Object-fit Property - W3Schools
-
Aspect-ratio - CSS: Cascading Style Sheets - MDN Web Docs - Mozilla
-
Emulating Background-size: Cover For HTML5 Video (CSS Only)
-
The Complete Guide To Understanding Video Aspect Ratios - Dacast
-
Video Fit To Screen Html
-
Fix Aspect Ratio Of Online Videos - Alexander Pruss's Blog
-
Css – Make HTML5 Video Poster Be Same Size As Video Itself