All perfect praise be to Allah, The Lord of The Worlds; and may His blessings and peace be upon our Prophet Mohammad and upon all his family and companions.
Burying a dead person is intended for preserving him/her from abuse and protecting the living from him/her(disintegration).
There are certain restrictions and conditions in Sharia as regards a grave. In principle, it should be as high as a Shibr { an opened hand } in order to recognize its dweller, and there is no harm in writing on it. However, if the grave`s height exceeds a Shibr, then there are certain rulings in this regard, depending on the graveyard . If it was located in a public graveyard, endowed to all Muslims or to some of them, and there was no need for building on it such as fear of theft, or exhumation of the corpse by animals, then it is forbidden to build on it because this (building) would bear down on Muslims and deprive them from using the grave for burying another person after the corpse in it disintegrates into dust. This is the opinion of the four Muslim jurists: the Malikites, the Shafites, the Hanbalites, and the Hanafites.
Al-Khateeb Ash-Shirbini said: “ If the grave was built on while in a public graveyard-used for burying people of that country-, then the built structure, whether it was a dome, a house, or a mosque, should be destroyed because it bears down on people.” {Moghni Al-Mohtajj(2/55)}.
However, if there was a need for building on it, then there is no harm in doing so, even if it was located in a public graveyard. Nevertheless, if the grave was located in a non-endowed graveyard such as being within the property of the deceased or one of his relatives, building on it is considered reprehensible according to the majority of Muslim jurists.
However, the Malikites and some of the Hanbalites have permitted increasing the height of the grave as a sign to recognize its dweller.
Also, some jurists made another exception as mentioned in the book [Hashyat Ibn Abdeen 2/237}: “ It was said that building on the grave isn`t reprehensible if the deceased was from the scholars and the masters, provided that the graveyard isn`t a public one.” And Allah knows best.