Are single/double quotes allowed inside HTML attribute values?
Yes, both quotes are allowed in attribute values, but you must HTML-escape the quote you’re using as an attribute value delimiter, as well as other HTML-special characters like < and &: function encodeHTML(s) { return s.split(‘&’).join(‘&’).split(‘<‘).join(‘<’).split(‘”‘).join(‘"’).split(“‘”).join(‘'’); } var html=”<label my_attr=””+encodeHTML(attr_value)+'”>Text</label>’; However, you are usually much better off not trying to hack a document together from … Read more