As I put you in a comment, only CSS can not be done because (at the moment) there is no selector for ancestors or superior brothers. With Javascript / jQuery it would be really simple, you could do something like this:
// selecciona todos los h3 que estén dentro de un togglearea
$(".togglearea h3").each(function() {
// selecciona el .togglearea ancestro del h3 y pone el margen de 30
$(this).closest(".togglearea").css("margin-left", "30px");
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.0/jquery.min.js"></script>
<div class="togglearea"><div class="toggle"><h3>Titulo</h3></div></div>
<div class="togglearea"><div class="toggle">Titulo 2</div></div>
Although I said that it can not be done only with CSS, there is a way to do it without JS but certain restrictions must be fulfilled:
The h3
must be the first element.
Requires that there is nothing else outside the container of h3
The idea would be to set a margin of 30px for ALL the elements next to h3
using the sibling selector ~
. It would be something like this:
.togglearea h3,
.togglearea h3 ~ * {
margin-left:30px;
}
<div class="togglearea"><div class="toggle"><h3>Titulo</h3></div></div>
<div class="togglearea"><div class="toggle">Titulo 2</div></div>