Suggest an editImprove this articleRefine the answer for “How does CSS calculate an element's final size?”. Your changes go to moderation before they’re published.Approval requiredContentWhat you’re changing🇺🇸EN🇺🇦UAPreviewTitle (EN)Short answer (EN)**CSS calculates an element's final size according to the Box Model**, and the formula depends on `box-sizing`: with `content-box` (the default), `width`/`height` apply only to content, while padding, border, and margin are added on top; with `border-box`, they already include content + padding + border. **Key point:** `margin` never counts toward `width`/`height`, and `border-box` helps keep an element's size fixed.Shown above the full answer for quick recall.Answer (EN)ImageThe final size is calculated according to the **Box Model**. The formula depends on `box-sizing`. --- ### **1) With** `box-sizing: content-box` **(the default value)** `width` and `height` apply **only to content**. Actual width: ```javascript content width + padding-left + padding-right + border-left + border-right + margin-left + margin-right ``` Actual height: ```javascript content height + padding-top + padding-bottom + border-top + border-bottom + margin-top + margin-bottom ``` --- ### **2) With** `box-sizing: border-box` `width` and `height` include **content + padding + border**. Actual width: ```javascript width (padding and border already inside) + margin-left + margin-right ``` Actual height: ```javascript height (padding and border already inside) + margin-top + margin-bottom ``` --- ### **Key points** - `margin` **never** counts toward `width`/`height`, it is outer space. - `padding` and `border` **increase the size** only with `content-box`. - `border-box` helps keep sizes fixed. --- If you'd like, I can visualize this with an ASCII diagram or make a picture-diagram.For the reviewerNote to the moderator (optional)Visible only to the moderator. Helps review go faster.