get the_title_attribute by id

I’m creating a list with a few permalinks which I call to with <a href="<?php echo get_permalink($id); ?>" title=".... And for the title I want to call the_title_attribute(). But it seems it can only be called within a loop, and not by id. How do I correctly get a title attribute?

Note: The reason I want to use the_title_attributes(); is because I use html tags within some of my titles.

Solutions Collecting From Web of "get the_title_attribute by id"

hey just look in code and it also support fourth parameter post

global $post;    
the_title_attribute(array('post'=>$post));//post object

or

global $post;
the_title_attribute(array('post'=>$post->ID));//post id

so you can use it like

<a href="<?php echo get_permalink($id); ?>" title="<?php the_title_attribute(array('post'=>$id)); ?>"> //where $id is post id

Important Link

the_title_attribute

you can use

get_the_title($ID);

to get title by id later you can add html tags like ..

$title_before = " // your html tags";

$title_after = "// your html tags";

$new_title = $title_before .''.get_the_title($ID).''.$title_after;