28 lines
689 B
Markdown
28 lines
689 B
Markdown
---
|
||
title: Img Width Attribute
|
||
localeTitle: Img宽度属性
|
||
---
|
||
## Img宽度属性
|
||
|
||
HTML“width”属性指的是图像的宽度。引号中的值是像素数量。
|
||
|
||
例如,如果您已经通过`src`属性设置了图像链接,则可以添加width属性,如下所示:
|
||
|
||
```html
|
||
|
||
<!DOCTYPE html>
|
||
<html lang="en">
|
||
<head>
|
||
<title>Img Width Attribute</title>
|
||
</head>
|
||
<body>
|
||
<img src="image.png" alt="Image" width="100"/>
|
||
</body>
|
||
</html>
|
||
```
|
||
|
||
在上面的代码段中,有一个图像标记,图像的宽度设置为100像素。 `width="100"`
|
||
|
||
#### 更多信息:
|
||
|
||
[关于img标签的MDN文章](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/img) |