Taking into account that CSS rules combine in various ways, do the following two HTML snippets render the same in the general case?
If not, are there some reasonable cases when they do?
1)
<div class="outerrule">
<div class="innerrule1">content1</div>
<div class="innerrule2">content2</div>
</div>
2)
<div class="outerrule">
<div class="innerrule1">content1</div>
</div>
<div class="outerrule">
<div class="innerrule2">content2</div>
</div>
It depends on what the CSS is.
For example, if there is a CSS rule on
.outerrulethat adds a border, they will not render the same. See this example.If, on the other hand,
.outerrulejust has some font styling, they will render the same. See this example.It’s really all dependant on the CSS itself. The rules themselves are “preserved” in that they will apply equally to each of the new elements. (Assuming, as in your code, they are all classes.)