It was narrated from 'Aishah that the Messenger of Allah ﷺ gave permission for visiting the graves.
Visiting graves should be done with respect, humility, and moderation; one should not overdo it or make it into a ritualistic practice that goes against Islamic teachings. The Prophet Muhammad (peace be upon him) taught us that we should not cry excessively or wail when visiting the grave but rather recite prayers for mercy on behalf of the deceased person's soul instead. Additionally, one should avoid making supplications at the grave directly since this is considered shirk or associating partners with Allah which is strictly forbidden in Islam.