For instance,
given
<html dir=rtl>
<body>
<div>I am right to left</div>
<div>I am right to left
<div dir=ltr>I should be left to right
<div dir=rtl>I should be right to left</div>
</div>
</div>
</body>
</html>
I am asking this question because the nested content is generated and there is no way to know how deep this is going to be.
Ideally a CSS rule should be able to apply a certain rule based on it's deepest match.
The rule:
[dir=rtl] {
text-align:right;
}
will only match the first. Ideally, you'd want something like
[dir=rtl]:deepest {
text-align:right;
}
Update:
I realize that the framing of the question might still be a bit confusing, sorry about that!
Here is code that illustrates the problem:
.container {
padding:20px;
}
[dir=ltr] .container {
border:5px solid blue;
}
[dir=rtl] .container {
border:5px solid red;
}
<div id="searchHere">
<div dir=ltr>
<div class="container">
l t r
</div>
<div dir=rtl>
<div class="container">
r t l
</div>
<div>
<div class="container">
r t l
</div>
<div dir=ltr>
<div class="container">
l t r ( should be but is r t l colors instead )
</div>
</div>
</div>
</div>
</div>
</div>
To try to clarify what the goal is, it is to say that any match that is found at a deeper level, is what should be applied on all child matches.
This can be achieved using a unique identifier for instance, since that will override prior rules, or by using a more well defined css selector. The more well defined selector could be div > div > div > div
... however, given a dynamically generated content, it would be quite difficult to know the rule to define.