Instead of $comment->post_ID
use $comment->comment_post_ID
. Your code will look like following:
<?php $comments = get_comments('status=approve&number=5'); ?>
<ul id="recent_comments">
<?php foreach ($comments as $comment) { ?>
<li><p><strong><?php
$title = get_the_title($comment->comment_post_ID);
echo get_avatar( $comment, '45' );
echo strip_tags($comment->comment_author); ?></strong> commented on <a href="https://wordpress.stackexchange.com/questions/28690/<?php echo get_permalink($comment->comment_post_ID); ?>" rel="external nofollow" title="<?php echo $title; ?>"> <?php echo $title; ?></a>: <?php echo wp_html_excerpt( $comment->comment_content, 45 ); ?> (...)</p></li>
<?php } ?>
</ul>
You were doing right about adding comment’s div id at the end of URL for creating individual comment links. You need to add #comment-<?php echo $comment->comment_ID; ?>
at the end of post permalink.
Here is how the anchor tag should look like.
<a href="<?php echo get_permalink($comment->comment_post_ID); ?>#comment-<?php echo $comment->comment_ID; ?>" rel="external nofollow" title="<?php echo $title; ?>"> <?php echo $title; ?></a>