.innerWidth() gets or sets the width of matched elements including padding, but not border or margin (getter since 1.2.6; setter since 1.8). The getter returns a unitless pixel Number.
Syntax
Start with these common calls. Keep them short and readable.
jQuery
$("div").innerWidth() // Number → content + padding
$("div").innerWidth(100) // set inner width to 100px
$("div").innerWidth(fn) // per-element setter (1.8+)
.width() → content only
.innerWidth() → content + padding
.outerWidth() → content + padding + border
Call
What it does
.innerWidth()
Learn jQuery .innerWidth(): get or set width including padding as a unitless pixel Number, compare with .width() and .outerWidth(), callback setter since 1.8, examples, pitfalls, and FAQs.
Load jQuery before your script (CDN or local file), then wrap DOM work in $(function () { ... }) when needed.
Parameters
Parameter
Description
Step 1
Select a DOM element (not window or document).
Step 2
Call .innerWidth() with no args to read content + padding as a Number.
Step 3
Pass a Number or CSS string to set that inner width on every match.
Return Value
Return Value
Description
jQuery object
Most setters and traversing helpers return the jQuery collection so you can chain more methods.
Value / undefined
Getters usually return a value from the first matched element, or undefined when nothing applies.
jQuery Examples
Example 1 — Get Inner Width of a Paragraph
Official style: read content + padding as a unitless Number.
jQuery
var p = $("p").first();
console.log("innerWidth: " + p.innerWidth() + "px");
Setter..innerWidth(120) adjusts CSS width so the padded box is 120px wide.
Pixels. A bare Number means pixels; strings can use units like "50%".
Chain. The setter returns the jQuery object for further calls.
Frequently Asked Questions
.innerWidth() with no arguments returns the width of the first matched element including padding (not border or margin) as a unitless pixel Number. .innerWidth(value) or .innerWidth(function) sets that inner width on every matched element and returns the jQuery object for chaining.
.width() is content only. .innerWidth() adds horizontal padding. .outerWidth() adds padding and border (pass true to include margin). All getters return unitless Numbers.
No. The API is for elements only. Use $(window).width() for the viewport and $(document).width() for the full page.
The getter has been available since jQuery 1.2.6. The setter .innerWidth(value) and the callback form arrived in jQuery 1.8.
Calling .innerWidth() on an empty jQuery set returns undefined (null before jQuery 3.0). Always check that your selection matched something before using the Number.
No. Values can be wrong (often 0) when the element or a parent is hidden. Measure while visible. Fractional pixels are possible — do not assume an integer.