It is permissible to visit the graves with the following conditions:
1) One should visit the grave with the intention of remembering death.
2) One should not commit any type of Bid’āh at the grave.
3) There should be no intermingling of genders at the grave.
4) One should not mourn loudly, cry or lose control of his/her emotions at the grave.