I've a web app with a bunch of pages. Each page have a few of modal windows.
Such page with modals have structure as below:
<div class='page1'>
<p>Page 1 content here</p>
<div class='modal'><p>Modal window</p>
</div>
The question is how to separate css styles of modals and pages, i.e. to make page style not affect modal style.
For example, a style p { font-weight: 900 }
will affect both page and modal paragraphs.
To clarify: the question is not about how to write css selector which narrows selector by div.page + p, its question how to organize HTML for widgets as modals, which are contextually bound to certain elements/pages/components.
A simplest solution would be to put all those modals outside of the page components, but that would reduce readability because it would become not clear to which context modal belongs.