Hadith 1757
Abu Marthad Kannaz bin Husain (May Allah be pleased with him) said:
عن أبي مرثد كناز بن الحصين رضي الله عنه قال: سمعت رسول الله صلى الله عليه وسلم يقول: "لا تصلوا إلى القبور، ولا تجلسوا عليها" ((رواه مسلم)).
I heard the Messenger of Allah (ﷺ) saying: "Do not offer Salat (prayer) facing the graves and do not sit on them." [Muslim].
In plain words
The Prophet taught that one should not pray facing graves, nor sit on them. It keeps prayer directed to Allah alone and treats the resting places of the dead with respect.
Reference : Riyad as-Salihin 1757 In-book reference : Book 17, Hadith 247