Skip to content

Commit 14f1c1d

Browse files
authoredNov 28, 2024··
New page: HTMLLinkElement.sizes (#36995)
1 parent f5af74a commit 14f1c1d

File tree

1 file changed

+55
-0
lines changed
  • files/en-us/web/api/htmllinkelement/sizes

1 file changed

+55
-0
lines changed
 
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
---
2+
title: "HTMLLinkElement: sizes property"
3+
short-title: sizes
4+
slug: Web/API/HTMLLinkElement/sizes
5+
page-type: web-api-instance-property
6+
browser-compat: api.HTMLLinkElement.sizes
7+
---
8+
9+
{{APIRef("HTML DOM")}}
10+
11+
The readonly **`sizes`** property of the {{domxref("HTMLLinkElement")}} interfaces defines the sizes of the icons for visual media contained in the resource. It reflects the {{HTMLElement("link")}} element's [`sizes`](/en-US/docs/Web/HTML/Element/link#sizes) attribute, which takes a list of space-separated sizes, each in the format `<width in pixels>x<height in pixels>`, or the keyword `any`.
12+
13+
It is only relevant if the {{domxref("HTMLLinkElement.rel", "rel")}} is `icon` or a non-standard type like `apple-touch-icon`.
14+
15+
## Value
16+
17+
A {{domxref("DOMTokenList")}}
18+
19+
## Examples
20+
21+
```html
22+
<link rel="icon" sizes="72x72 114x114" href="smallish.png" />
23+
```
24+
25+
```js
26+
const link = document.querySelector("[rel=icon],[rel=apple-touch-icon]");
27+
console.dir(link.sizes); /* output:
28+
DOMTokenList [ "72x72", "114x114" ]
29+
0: "72x72"
30+
1: "114x114"
31+
length: 2
32+
value: "72x72 114x114"
33+
*/
34+
console.log(link.sizes.value); // output: '72x72 114x114'
35+
console.log(link.sizes.length); // output: 2'
36+
console.log(link.sizes[0]); // output: '72x72'
37+
console.log(link.sizes[1]); // output: '114x114'
38+
```
39+
40+
## Specifications
41+
42+
{{Specifications}}
43+
44+
## Browser compatibility
45+
46+
{{Compat}}
47+
48+
## See also
49+
50+
- {{domxref("HTMLLinkElement.rel")}}
51+
- {{domxref("HTMLLinkElement.relList")}}
52+
- {{domxref("HTMLLinkElement.type")}}
53+
- {{domxref("HTMLLinkElement.href")}}
54+
- {{HTMLElement("link")}}
55+
- [`rel`](/en-US/docs/Web/HTML/Attributes/rel) attribute

0 commit comments

Comments
 (0)
Please sign in to comment.