Praise be to Allah.
The time for Tarawih prayer lasts from after `Isha until dawn comes, so it is valid to perform this prayer at any time during this period.
Al-Nawawi (may Allah have mercy on him) said in al-Majmu’:
“The time of Tarawih prayer begins when the ‘Isha prayer is over, as was stated by al-Baghawi and others, and it lasts until dawn comes.”
But if a man is going to pray in the mosque as an imam leading the people in prayer, it is better to pray Tarawih after `Isha prayer and not to delay it until the middle or the end of the night, so that this will not cause hardship for the worshippers and some of them may sleep and miss the prayer. This is what the Muslims usually do, they pray Tarawih after `Isha and do not delay it.
Ibn Qudamah said in al-Mughni:
“It was said to Imam Ahmad: Will you delay qiyam – i.e., Tarawih – until the end of the night? He said, No, the practice of the Muslims is dearer to me.”
But for one who prays Tarawih at home , he has the choice: if he wants, he can pray it at the beginning of the night and if he wants he can pray it at the end.
And Allah knows best.