height (HTML attribute)

Depr. Version
Yes N/A


height="height in pixels"


An embed does not require a height attribute, but it has its uses. The main use for specifying the height (and width) is to improve the experience for a user while a page is loading. If the dimensions are specified in the markup, as the page is loaded the space required for the object is ‘reserved’ by the browser; without this information, the browser does not know how big the object is and cannot allocate the necessary space. On a slow-loading page, the effect can be quite disturbing as content is constantly re-flowed as each new object appears on the page.

The downside of specifying a height (and width) is that if you later decide to update an embedded file that is used site-wide it would require changing all the dimension attributes for each page. Depending on how your web site is managed (manually, template-driven, CMS, server-side includes), this may be a minor niggle or a real issue for you. It is a case of weighing up the pros and cons.

If the height attribute is set by itself, but no width attribute is set, the image will be rescaled proportionally. And depending on the type of content in the embed and the browser rendering it, if non-proportional dimensions are specified (e.g. a 200 x 200 pixel object is set to 100 and 300 pixels in height and width respectively), the results vary (image objects can be stretched/squashed just as they can when applied using the img element, but multimedia objects may not distort in the same way).


The height attribute set to "100":

<embed src="giant-grasshopper.jpg" width="300" height="100"></embed>


A number representing the height of the object in pixels.


The compatibility of this attribute is dependent on the type of object. For image type objects, there is reasonable cross-browser support for the height attribute.

User-contributed notes

There are no comments yet.

Related Products