forked from mdn/content
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
init documentation for
HTMLSourceElement.{height,width}
(mdn#32106)
* init docs * add additional links * Apply suggestions from code review Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: dawei-wang <[email protected]> * Update files/en-us/web/api/htmlsourceelement/height/index.md * Update files/en-us/web/api/htmlsourceelement/height/index.md * Update files/en-us/web/api/htmlsourceelement/width/index.md * Update files/en-us/web/api/htmlsourceelement/width/index.md --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: dawei-wang <[email protected]> Co-authored-by: Jean-Yves Perrier <[email protected]>
- Loading branch information
1 parent
952db47
commit d8a5256
Showing
15 changed files
with
178 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
--- | ||
title: "HTMLSourceElement: height property" | ||
short-title: height | ||
slug: Web/API/HTMLSourceElement/height | ||
page-type: web-api-instance-property | ||
browser-compat: api.HTMLSourceElement.height | ||
--- | ||
|
||
{{APIRef("HTML DOM")}} | ||
|
||
The **`height`** property of the {{domxref("HTMLSourceElement")}} interface is a non-negative number indicating the height of the image resource in CSS pixels. | ||
|
||
The property has an effect only if the parent of the current {{HTMLElement("source")}} element is a {{HTMLElement("picture")}} element. | ||
|
||
It reflects the `height` attribute of the {{HTMLElement("source")}} element. | ||
|
||
## Value | ||
|
||
A non-negative number indicating the height of the image resource in CSS pixels. | ||
|
||
## Examples | ||
|
||
```html | ||
<picture id="img"> | ||
<source | ||
srcset="landscape.png" | ||
media="(min-width: 1000px)" | ||
width="1000" | ||
height="400" /> | ||
<source | ||
srcset="square.png" | ||
media="(min-width: 800px)" | ||
width="800" | ||
height="800" /> | ||
<source | ||
srcset="portrait.png" | ||
media="(min-width: 600px)" | ||
width="600" | ||
height="800" /> | ||
<img | ||
src="fallback.png" | ||
alt="Image used when the browser does not support the sources" | ||
width="500" | ||
height="400" /> | ||
</picture> | ||
``` | ||
|
||
```js | ||
const img = document.getElementById("img"); | ||
const sources = img.querySelectorAll("source"); | ||
console.log(Array.from(sources).map((el) => el.height)); // Output: [400, 800, 800] | ||
``` | ||
|
||
## Specifications | ||
|
||
{{Specifications}} | ||
|
||
## Browser compatibility | ||
|
||
{{Compat}} | ||
|
||
## See also | ||
|
||
- {{domxref("HTMLCanvasElement.height")}} | ||
- {{domxref("HTMLEmbedElement.height")}} | ||
- {{domxref("HTMLIFrameElement.height")}} | ||
- {{domxref("HTMLImageElement.height")}} | ||
- {{domxref("HTMLObjectElement.height")}} | ||
- {{domxref("HTMLVideoElement.height")}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
--- | ||
title: "HTMLSourceElement: width property" | ||
short-title: width | ||
slug: Web/API/HTMLSourceElement/width | ||
page-type: web-api-instance-property | ||
browser-compat: api.HTMLSourceElement.width | ||
--- | ||
|
||
{{APIRef("HTML DOM")}} | ||
|
||
The **`width`** property of the {{domxref("HTMLSourceElement")}} interface is a non-negative number indicating the width of the image resource in CSS pixels. | ||
|
||
The property has an effect only if the parent of the current {{HTMLElement("source")}} element is a {{HTMLElement("picture")}} element. | ||
|
||
It reflects the `width` attribute of the {{HTMLElement("source")}} element. | ||
|
||
## Value | ||
|
||
A non-negative number indicating the width of the image resource in CSS pixels. | ||
|
||
## Examples | ||
|
||
```html | ||
<picture id="img"> | ||
<source | ||
srcset="landscape.png" | ||
media="(min-width: 1000px)" | ||
width="1000" | ||
height="400" /> | ||
<source | ||
srcset="square.png" | ||
media="(min-width: 800px)" | ||
width="800" | ||
height="800" /> | ||
<source | ||
srcset="portrait.png" | ||
media="(min-width: 600px)" | ||
width="600" | ||
height="800" /> | ||
<img | ||
src="fallback.png" | ||
alt="Image used when the browser does not support the sources" | ||
width="500" | ||
height="400" /> | ||
</picture> | ||
``` | ||
|
||
```js | ||
const img = document.getElementById("img"); | ||
const sources = img.querySelectorAll("source"); | ||
console.log(Array.from(sources).map((el) => el.width)); // Output: [1000, 800, 600] | ||
``` | ||
|
||
## Specifications | ||
|
||
{{Specifications}} | ||
|
||
## Browser compatibility | ||
|
||
{{Compat}} | ||
|
||
## See also | ||
|
||
- {{domxref("HTMLCanvasElement.width")}} | ||
- {{domxref("HTMLEmbedElement.width")}} | ||
- {{domxref("HTMLIFrameElement.width")}} | ||
- {{domxref("HTMLImageElement.width")}} | ||
- {{domxref("HTMLObjectElement.width")}} | ||
- {{domxref("HTMLVideoElement.width")}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters