jQuery .boxModel Property

Beginner
5 min read
Updated: Nov 2026
3 examples
Utilities

Definition

jQuery.boxModel (alias $.boxModel) was a Boolean that reported whether the browser was using the W3C CSS box model (true, standards mode) or the older quirks-mode box model (false). It was added in jQuery 1.0, deprecated in 1.3 and removed in 1.8, so in jQuery 3.x it is undefined.

Syntax

Start with these common calls. Keep them short and readable.

jQuery
$.boxModel          → true | false   (jQuery 1.7 and older only)

// Modern jQuery 1.8+ / 3.x:
typeof $.boxModel   → "undefined"

// Modern replacements
document.compatMode === "CSS1Compat"     // standards mode
getComputedStyle(el).boxSizing           // "content-box" | "border-box"
CallWhat it does
$.boxModelLegacy flag: true for the W3C box model, false in quirks mode.
typeof $.boxModel"undefined" in jQuery 1.8+ — guard before reading it.
document.compatMode"CSS1Compat" (standards) or "BackCompat" (quirks).
getComputedStyle(el).boxSizingPer-element content-box or border-box sizing.

Read $.boxModel only with a guard such as typeof $.boxModel !== "undefined". On jQuery 3.7.1 the property does not exist.

Parameters

StepDescription
Step 1Confirm your jQuery version — the property exists only before 1.8.
Step 2Guard the read: typeof $.boxModel !== "undefined".
Step 3Prefer document.compatMode and CSS box-sizing in new code.

Return Value

Return ValueDescription
Boolean (legacy)true when the page used the W3C box model; false in quirks mode.
undefined (modern)jQuery 1.8+ and 3.x do not define the property, so reading it gives undefined.

jQuery Examples

Example 1 — Official Demo (with a Guard)

The old API sample printed the box model into the page. Add a guard so it also runs on modern jQuery.

jQuery
// jQuery <= 1.7 returned true or false; modern jQuery has no such property.
var model = typeof $.boxModel === "undefined"
  ? "(not available)"
  : String($.boxModel);

$("#msg").html("The box model for this page is: <span>" + model + "</span>");
console.log($("#msg").text());
Try It Yourself

How It Works

  1. Guard. typeof $.boxModel avoids a crash when the property is missing.
  2. Build. The message uses String($.boxModel) only on legacy jQuery.
  3. Result. On jQuery 3.7.1 you see (not available); on 1.7 you saw true or false.

Example 2 — Detect Standards Mode with compatMode

The modern way to know whether the page uses standards mode (the W3C box model).

jQuery
var standards = document.compatMode === "CSS1Compat";

console.log(document.compatMode);  // "CSS1Compat" (page has a doctype)
console.log(standards);            // true
Try It Yourself

How It Works

  1. Property. document.compatMode is a built-in browser property.
  2. Standards. "CSS1Compat" means the doctype triggered standards mode.
  3. Quirks. "BackCompat" would mean quirks mode (the old IE box model).

Example 3 — Read box-sizing Instead

Modern layouts choose the box model per element with CSS box-sizing.

jQuery
var el = document.getElementById("box");   // width:100px; padding:10px; border:5px

console.log(getComputedStyle(el).boxSizing);  // "content-box"
console.log($(el).outerWidth());              // 130  (100 + 20 + 10)

el.style.boxSizing = "border-box";
console.log($(el).outerWidth());              // 100
Try It Yourself

How It Works

  1. Read. getComputedStyle(el).boxSizing returns the box model for that element.
  2. Measure. With content-box, padding and border add to the 100px width.
  3. Switch. border-box keeps the outer width at 100px.

Frequently Asked Questions

jQuery.boxModel was a Boolean property that told you whether the browser rendered the page with the W3C CSS box model (true) or the quirks-mode box model (false). It was added in jQuery 1.0 to help with old Internet Explorer layout differences.
No. It was deprecated in jQuery 1.3 and removed in 1.8. In jQuery 3.x, $.boxModel is undefined, so reading it does not give you a Boolean.
jQuery 1.3 pointed to jQuery.support.boxModel as the replacement, but that flag is gone from modern jQuery too. Use native checks instead: document.compatMode for the page mode and getComputedStyle(el).boxSizing for individual elements.
A valid doctype such as <!DOCTYPE html> puts the browser in standards mode (document.compatMode is "CSS1Compat"). A missing or old doctype triggers quirks mode ("BackCompat"), which mimics legacy rendering, including the old box model.
Always include <!DOCTYPE html> and set box-sizing explicitly, for example * { box-sizing: border-box; }. Then width and height include padding and border everywhere, and you rarely need to detect the box model.
jQuery handles the difference for you. .width() returns the content width, and .outerWidth() adds padding and border, regardless of box-sizing, so you can measure without checking any box-model flag.

Next: jQuery.error() Method

Learn how jQuery throws a named error for plugin authors.

jQuery.error() Method tutorial →

CODETOFUN NEWS

Stay Ahead in Tech

Get the latest IT news, programming updates, and technology trends directly on your phone.

Your daily dose of tech, straight to your feed.

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

8 people found this page helpful