title: Add '*' to the label of input fields with the 'required' attribute with CSS
body: <p>I am wondering if there is a way using only CSS to add an asterisk to a <code>label</code> element when the label's <code>for</code> attribute is for an <code>input</code> element with a <code>required</code> html attribute. Alternatively, we could use logic around if the <code>label</code> is directly followed by an <code>input</code> element which has the <code>required</code> attribute.</p>
  
  <p>What does work is something like this:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-css lang-css prettyprint-override"><code>input[required] + label:after {
    content: '*';
    color: red;
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;form&gt;
    &lt;div&gt;
      &lt;input for="name" type="text" required /&gt;
      &lt;label id="name"&gt;Name&lt;/label&gt;
    &lt;/div&gt;
    &lt;div&gt;
      &lt;input for="age" type="text" /&gt;
      &lt;label id="age"&gt;Age&lt;/label&gt;
    &lt;/div&gt;
  &lt;/form&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>But what I'm talking about is if the <code>label</code> and <code>input</code> are swapped around like the example below, which is more common. The CSS sibling selector <code>+</code> doesn't work for this case. Is there any way to do some like above when the <code>label</code> element is first and the <code>input</code> is second?</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-css lang-css prettyprint-override"><code>/* ??? */</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;form&gt;
    &lt;div&gt;
      &lt;label for="name"&gt;Name&lt;/label&gt;
      &lt;input id="name" type="text" required /&gt;
    &lt;/div&gt;
    &lt;div&gt;
      &lt;label for="age"&gt;Age&lt;/label&gt;
      &lt;input id="age" type="text" /&gt;
    &lt;/div&gt;
  &lt;/form&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>Thanks</p>