title: Sass - Target an ID restrict certain styles if it has matching class then add other styles set by class
body: <h1>Question</h1>
  
  <p>I need to target a <code>&lt;section&gt;</code> with a specific ID that will show up once in every page. But each will have a unique class. Some of the styles for the section will not apply if that class is added dynamically. Trying to figure out how to best nest the styling using Sass.</p>
  
  <h3>Code</h3>
  
  <h2>Demo</h2>
  
  <p>Here is a demo on <a href="http://codepen.io/JGallardo/pen/pEkoEB" rel="nofollow">CodePen</a>.
  Because it has the class of <code>.soldout</code>, the background should be grey not red.</p>
  
  <p><a href="https://i.stack.imgur.com/xRVnQ.jpg" rel="nofollow"><img src="https://i.stack.imgur.com/xRVnQ.jpg" alt="enter image description here"></a></p>
  
  <h3>HTML</h3>
  
  <pre><code>&lt;section id="featured-product" class="soldout"&gt;
    &lt;h1&gt;This car is no longer avaiable&lt;/h1&gt;
    &lt;img src="https://img.gta5-mods.com/q95/images/2013-lamborghini-veneno-hq-digitaldials/bb4811-venenomain.jpg"&gt;
  &lt;/section&gt;
  </code></pre>
  
  <h3>SCSS</h3>
  
  <pre><code>#featured-product {
    /* these styles always apply */
    color: #f1f1f1;
    font-family: 'Oswald', sans-serif;
    text-align:center;
  
  
    /* These classes should not apply if the section has a class of .soldout */
    background: #FC332E;
    padding: 25px 30px 45px;
  
    &amp; .soldout {
      /* These styles only apply when the element has matching ID and this class added in*/
      background: #BDBEBA;
      padding: 25px;
    }
    img { width: 400px; }
  }
  </code></pre>