HTML <object> width Attribute

The width attribute on an <object> tag sets the width of the object element. The width is specified in pixels -- without the ‘px‘ unit.

Example

#

A width attribute on an <object> element.
This object has a width attribute and a CSS width property; CSS width takes precedence, i.e. wins.

<object data="/media/sample.pdf" type="application/pdf"
        width="800" height="450" style="width:100%">
</object>

Using width

The width attribute sets the width of the object.

HTML5 states that the width is defined in pixels, although some browsers also support %.

If % or another unit is required, use the CSS width property.


Syntax

<object data="value" width="pixels">

Note: The width attribute requires that data has a value.

Values

#

Value Description
pixels A number (e.g. 500).

Browser support

Here is when width support started for each browser:

Chrome
1.0 Sep 2008
Firefox
1.0 Sep 2002
IE/Edge
1.0 Aug 1995
Opera
1.0 Jan 2006
Safari
1.0 Jan 2003

You may also like

 Back to <object>
Guides