jQuery outerWidth() method
Example
Return
The outer width of the element:
false - Default. Does not include the margin.
true - Includes the margin.
|
$
(
"
button
"
)
.
click
(
function
(
)
{
alert
(
$
(
"
div
"
)
.
outerWidth
(
)
)
;
}
)
;
Try it »
Definition and Usage
The outerWidth() method returns the outer width of the first matched element.
As shown in the image below, this method includes padding and border.
**Tip:** To include the margin, use outerWidth(true).

Related methods:
- width() - Sets or returns the width of an element
- height() - Sets or returns the height of an element
- innerWidth() - Returns the width of an element (including padding)
- innerHeight() - Returns the height of an element (including padding)
- outerHeight() - Returns the height of an element (including padding and border)
Syntax
$(
selector
).outerWidth(
includeMargin
)
| Parameters | Description |
|---|---|
| includeMargin | Optional. A boolean that specifies whether to include the margin.
|
More examples
Including the margin
Specifies whether to include the margin.
Display dimensions with related methods
How to use width(), height(), innerHeight(), innerWidth(), outerWidth(), and outerHeight().
jQuery HTML/CSS methods