Apostrophes - Correct Usage in HyperLinks

Best Practices

When HTML or JavaScript is generated in code, care must be taken in the usage of apostrophes.

HREF Attributes




 ACCEPTABLE:<A HREF="http://www.google.com">Google</a>
 NOT ACCEPTABLE: <A HREF='http://www.google.com'>Google</a>


JavaScript String Literals


 ACCEPTABLE:alert("Hello world");
 NOT ACCEPTABLE: alert('Hello world');


 ACCEPTABLE:alert('We\'re number one!');
 NOT ACCEPTABLE: alert('We're number one!');