title: Javascript - check if string is valid CSS color?
body: <p>If a color string is a number, then we can use a <code>RegExp</code> to check if it's a valid CSS color. But what if it's a word?</p>
  
  <p>I have code that generates controls dynamically from colors arguments. But instead of color, there could be <code>null</code>, <code>""</code>, or random words. Is there a way to check color name with Javascript?</p>
  
  <p><strong>Update:</strong> Thank you much for the great answer! :)
  My final version is below (added a <code>toLowerCase()</code> check because the color could be <code>"Green"</code>, <code>"Red"</code>, etc.).</p>
  
  <pre><code>function isValidColor(strColor) {
    var s = new Option().style;
    s.color = strColor;
  
    // return 'false' if color wasn't assigned
    return s.color == strColor.toLowerCase();
  }
  </code></pre>