I've been searching for a reliable method to achieve my goal, but haven't found one yet. However, I thought I'd reach out to the experts here to see if they have any ideas.
My aim is to develop a simpler way of styling that allows users to utilize a single tag with a class or ID to mimic the formatting of nested tags. For instance, I want a DIV to appear as if it contains another DIV within it, enabling more sophisticated styling that typically requires nested elements.
Here is an example of what I envision:
<div class="nesteddiv">{content}</div>
which would render as:
<div class="outerdiv"><div class="innerdiv">{content}</div></div>
The intention is to have the outerdiv and innerdiv possess their own borders, backgrounds, margins, and spacing to produce a complex style that cannot be achieved with a single DIV (as far as I am aware, a single DIV cannot have multiple borders).
I am aware of pseudo-elements like ::before and ::after which allow you to insert content before and after the existing content of an element, but these cannot render HTML tags when inserted. Are there alternative methods to transform a single HTML element into something that looks like multiple nested elements? I prefer not to use Javascript due to some viewers having it disabled. While I know Javascript offers options such as creating custom elements or replacing all DIVs with a specific class with more intricate nested code, I would rather find a simpler solution using pure HTML/CSS.