 <p>If you're speaking of HTML5 id, then the requirement is</p> <blockquote> <p>The value must be unique amongst all the IDs in the element’s home subtree and must contain at least one character. The value must not contain any space characters.</p> </blockquote> <p>Which gives this regex :</p> <pre><code>^[\S]+$ </code></pre> <p>If you're speaking of HTML4 (don't see why but well) then I guess it's a duplicate. See <a href="http://stackoverflow.com/questions/14664860/allowed-html-4-01-id-values-regex">Allowed HTML 4.01 id values regex</a></p>