Skip to content

QuizNot attempted

offsetWidth vs clientWidth vs scrollWidth

A div has 10px borders and 20px padding. Which property includes the border?
1–4 to choose, Enter to submit
Show answer & explanation

Correct answer:

  • offsetWidth
  • offsetWidth is the rendered box: content + padding + border (+ scrollbar).
  • Not clientWidth: content + padding only, it excludes the border.
  • Not scrollWidth: the full scrollable content width including overflow, also border-excluded.
  • Not clientLeft: that is just the left border's thickness (10px), not the element's width.