The id attribute is one of the least suitable places for this (it must be unique, cannot contain all characters). Use the data- attribute (introduced in HTML5, but also working in older browsers and without using an HTML document):
<a href="#" data-desc="....">
If you use jQuery, you can access it via .data('desc') , in normal JavaScript the most portable way is .getAttribute('data-desc') . If you do not need to support older browsers, you can access the value using the .dataset.desc property.
In any case, you need to make sure that when you insert dynamic data into the attribute, nothing will break. Use htmlspecialchars() for this purpose:
$desc = '<p style="color: red">some <span>data</span></p>'; echo '<a href="#" data-desc="' . htmlspecialchars($desc) . '">' . $key . '</a>';
source share