title: Use CSS to automatically add 'required field' asterisk to form inputs
body: <p>What is a good way to overcome the unfortunate fact that this code will not work as desired:</p>
  
  <pre><code>&lt;div class="required"&gt;
      &lt;label&gt;Name:&lt;/label&gt;
      &lt;input type="text"&gt;
  &lt;/div&gt;
  
  &lt;style&gt;
      .required input:after { content:"*"; }
  &lt;/style&gt;
  </code></pre>
  
  <p>In a perfect world, all required <code>input</code>s would get the little asterisk indicating that the field is required. This solution impossible since the CSS is inserted after the element content, not after the element itself, but something like it would be ideal. On a site with thousands of required fields, I can move the asterisk in front of the input with one change to one line (<code>:after</code> to <code>:before</code>) or I can move it to the end of the label (<code>.required label:after</code>) or in front of the label, or to a position on the containing box, etc... </p>
  
  <p>This is important not just in case I change my mind about where to place the asterisk everywhere, but also for odd cases where the form layout doesn't allow the asterisk in the standard position. It also plays well with validation that checks the form or highlights improperly completed controls.</p>
  
  <p>Lastly, it doesn't add additional markup.</p>
  
  <p>Are there any good solutions that have all or most of the advantages of the impossible code?</p>