0

Is it during the construction of the CSSOM (where possibly default padding/border/margin is applied to all nodes)?

Joel Castro
  • 485
  • 6
  • 20

1 Answers1

2

An element's box is (re)calculated in what is called the "update layout" phase, which is currently specified* as happening (at least) inside the next "update the rendering" step of the event-loop, at sub-step 14:

  1. For each fully active Document doc in docs:
  • Recalculate styles and update layout for doc

but it can also be forced synchronously when calling some getters.

*Though this is a quite recent addition to the specs and not all browsers do follow it exactly, for instance I know from experience that to do this layout update Safari will not wait for the next "painting frame", but just some idle time.

Kaiido
  • 123,334
  • 13
  • 219
  • 285