title: Styling a div only if another div exists in the parent div with css
body: <p>I want to style a div only if a certain other div exists inside the parent. Just look at the following piece of code. The parent div is <code>'main'</code>, and inside this parent div there are two child divs, that is <code>&quot;first&quot;</code> and <code>&quot;second&quot;</code>. I want to style the div <code>&quot;second&quot;</code> only if the div <code>&quot;first&quot;</code> exists inside the parent div, that is <code>&quot;main&quot;</code>. It is possible that sometimes the <code>&quot;first&quot;</code> div is not inside the main div. Is it possible to do this with CSS?
  Millions of thanks in advance.</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="false" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-css lang-css prettyprint-override"><code>&lt;div id="main"&gt;
              &lt;div id="first"&gt;&lt;/div&gt;
              ...some other divs...
              &lt;div id="second"&gt;&lt;/div&gt;
          &lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>