Title rewritten to: CSS > Select first element in tree
P粉237125700
2023-08-31 19:48:34
<p>I've been trying to select only the first blockquote in the body of the email, which goes something like this: </p>
<pre class="brush:php;toolbar:false;"><div class="myclass">
<br><p></p>
<div><div> <!--sometimes less, sometimes more divs-->
<blockquote> <!--The blockquote I want to select-->
<div> <div> <br>
<blockquote>
<Wait...>
</blockquote>
</div> </div>
</blockquote>
</div></div>
</div></pre>
<p>The problem is, the formatting may vary from email to email, and there may be one or more divs before the first blockquote,</p><p>
So use: </p>
<pre class="brush:php;toolbar:false;">.myclass > div > div > blockquote {}</pre>
<p>Not always valid,</p><p>
This: </p>
<pre class="brush:php;toolbar:false;">.myclass blockquote:first-of-type {}</pre>
<p>Each blockquote will be selected</p>
<p>So I only want to select the first blockquote regardless of its position on the html tree. </p>
Like this? Selects the first nested
blockquote
of the container.myclass
, but does not select anyblockquote## that is a child of the first
blockquote#.