jQuery Home

Dimensions

jQuery width() and height() Methods

The width() method sets or returns the width of an element (excludes padding, border and margin).

The height() method sets or returns the height of an element (excludes padding, border and margin).




The innerWidth() method returns the width of an element (includes padding).

The innerHeight() method returns the height of an element (includes padding).




The outerWidth() method returns the width of an element (includes padding and border).

The outerHeight() method returns the height of an element (includes padding and border).




The outerWidth(true) method returns the width of an element (includes padding, border, and margin).

The outerHeight(true) method returns the height of an element (includes padding, border, and margin).




The following example returns the width and height of the document (the HTML document) and window (the browser viewport).




The following example sets the width and height of a specified <div> element.

Both dimensions will resize to 300 px.