Object width attribute

Definition and Usage

Width Attribute setting or returning the height of the <object> element Width attribute value.

The width attribute specifies the width of the object in pixels.

Tip:Use Height attribute Set or return the height of the <object> element Height attribute value.

See also:

HTML Reference Manual:HTML <object> width Attribute

HTML Reference Manual:HTML <object> Tag

Instance

Example 1

Change the width of the <object> element to 400px:

document.getElementById("myObject").width = "400";

Try it yourself

Example 2

Get the width of the <object> element:

var x = document.getElementById("myObject").width;

Try it yourself

Example 3

Change the height and width of the <object> element to 300px:

document.getElementById("myObject").height = "500";
document.getElementById("myObject").width = "500";

Try it yourself

Syntax

Return the width attribute:

objObject.width

Set the width attribute:

objObject.width = pixels

Attribute value

Value Description
pixels Specifies the width of the object in pixels (for example, height="100").

Technical Details

Return Value: Number, representing the width of the object in pixels.

Browser Support

Chrome Edge Firefox Safari Opera
Chrome Edge Firefox Safari Opera
Support Support Support Support Support