Your code is fine, the only problem here is a syntax error. Always remember to remove any spaces between the opening and closing tags – otherwise your code will fail.
Example:
<h2>
<a href="#" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>">
<?php the_title(); ?>
</a>
</h2>
Make sure to read the WordPress Codex about the_title_attribute()
to understand better on how to customize this function: https://codex.wordpress.org/Function_Reference/the_title_attribute