HTML width attribute

width attribute represents the horizontal dimension of the media, iframe, image or video.

Example


<img src="files/web.png" width="100%" height="400">
Try </>

width attribute value

The value of width attribute is a positive integer. By default, the unit of width is pixels. 400 means 400px.

CSS properties may also be applied to define the width.

<img src="URL" style="width:100%; height:200px;">

There are various units of width.

Related Tags

The tags that support this attribute are as follows.

<embed> tag

It embeds external resources such as image, HTML page.

<embed src="URL" width="100%" height="300">

<iframe> tag

iframe represents a browsing context to browse the content.

<iframe src="URL" style="width:100%; height:200px;"> </iframe>

<img> tag

img tag adds an image in the page. img element supports the width attributes.

See the example given above.

<video> tag

video tag adds an image in the page. width defines horizontal dimension.

<video src="URL" height="500" width="100%"> </video>

Was this article helpful?

 

Email:

Message:

Get the newsletter