The contain property in CSS enables elements to be independent within the document tree, leading to performance benefits by isolating a subsection of the DOM. Four types of containment – size, layout, style, and paint – can be applied to a container, preventing the re-render of the DOM and enhancing performance. Containment can isolate elements’ internal layout, prevent visual overflow, and scope CSS counters and quotes within an element. Different values for the contain property offer specific effects, such as strict applying all containment rules, while content excludes size containment. Implementing containment improves rendering performance for both static and dynamic web applications.
https://developer.mozilla.org/en-US/docs/Web/CSS/contain