All perfect praise be to Allah, The Lord of the Worlds. I testify that there is none worthy of worship except Allah, and that Muhammad is His slave and Messenger.
There are some rulings and good manners pertaining to washing a dead person. First, anyone who wants to wash a dead person, has to conceal the dead's ‘Awrah. So, he must cover the dead man between the navel and the knee. If the dead is a woman, the women washing her must first cover her ‘Awrah (front of the woman between the navel and the knee). Then the dead person's clothes are removed except that which covers the ‘Awrah. It is desirable that the dead person be concealed from the eyes of people while being washed and it is dislikable for anyone who is not helping in the washing to attend it. Then, the corpse is placed on the washing bed or on an elevated place. After that, the head of the dead person is tilted forward until the body is almost in a seated position and his stomach is then squeezed carefully. Next, water is poured on him/her thoroughly and the person doing the washing uses a piece of cloth in his hand to wash the dead's private parts (front and back). He should not, however, touch the ‘Awrah of any person aged 7 years or more unless one wears a covering on his hands. It is dislikable to touch any part of the body without screening the hands from directly touching the skin of the dead person.
He may then perform ablution on him as the Prophet said to those who washed his daughter: "Begin washing the dead by washing the organs on the right-hand side, and those parts that are washed in ablution." [Al-Bukhari and Muslim]
He should not put water in the deceased's nose or mouth but uses his wet fingers to wipe over his teeth and places them in his nostrils to clean them. His fingers should then be covered. Next, he begins the washing starting by saying "Bismillah" (in the Name of Allah). The head and beard are cleaned with the foam of Sidr (lotus jujube). The Sidr is pounded and put in a receptacle with some water. Then, it is beaten by hand until it has a foam. Only the foam is used to clean the head and the beard as to avoid having residue stick to the hair. In fact, the foam does not contain any sediments.
Afterwards, the right-hand side of the corpse is washed, then the left-hand side, and finally the whole body three times, or five times, or seven times or more, depending on the situation. But the number of washings has to be uneven as the Prophet said: "Wash the dead body an odd number of times; that is three, five, seven, or more if you feel that it is necessary." [Al-Bukhari and Muslim]
During each washing, one has to pass his hand over the stomach of the dead.
Some camphor should be put in the last washing as the Prophet said: "For the final washing, use some camphor or something from camphor. When you are finished, inform me." [Al-Bukhari and Muslim]
Camphor has a good smell so it has a special effect on reducing the dead body's odor. There is no harm in using soap if there is a need for it.
Some scholars state that the dead's nails should be cut and a man's moustache should be trimmed but his hair should not be combed but should be dried with a piece of cloth.
If some impurities come out of the dead body after the seven washing, then the outlet is filled with some cotton and the place is washed and ablution is performed on the dead person. But if this impurity comes out after it has been enshrouded, then the Ghusl is not done again. The hair of a woman is trussed in three junctions and let hang on her back.
A person who washes a dead person should be trustworthy, honest, and cognizant of rulings of Ghusl (washing). It is prohibited for the person who washes the dead to mention any disliked things about the latter unless there is some need, and if the former sees any good sign about the dead, it is desirable to tell others so that they will shower him with supplication. Also, this might be a good example.
If the deceased was an innovator and the one who washed him saw some bad signs, it would be advisable to tell others to be cautious of his opinion and way of life.
Then, the best one to wash a dead person is his father or grandfather or blood relative.
As for a woman, it is better to be washed by her guardian, and, if not, by her women relatives.
However, one spouse can wash the other. And a man or a woman can wash a seven-year old child since there is no fixed ruling concerning his or her private parts.
As for shrouding the dead person, it is advisable to shroud him with three perfumed white covers. The three covers should be put on each other and the deceased be laying down on them. We put some perfumed cotton between his buttocks and then cover them with some clothing like shorts. Then, we perfume his face and so on. After that, we cover him with the first cover, right first, then we use the second and third covers in the same way, leaving the ends near his head to be tied, then untied in the grave.
If we shroud him with a shirt, a loin cloth and a wrap that is sufficient and legal. It is desirable to shroud a dead woman with five pieces of cloth; a loin cloth, head cover, a shirt and two pieces of clothes. But, shrouding the deceased with one wrap that covers the whole body is a must.
The Sunnah describes the way of burial as follows:
1- Dig the Lahd (a crevice made on the side of a grave facing al-Qiblah) that fits and covers the dead body. This is the opinion of the majority of the scholars for the Prophetic Hadeeth: "The niche-grave (Lahd) is for us (the Muslims) and the ditch-grave is for others." [Abu Dawood and At-Tirmithi]
Some jurists think that Lahd is better as long as the earth is solid; otherwise the ditch-grave is safer. Lahd must be wide and deep as the height of a normal man for the Prophetic Hadeeth: "Dig and make wide and deep." [At-Tirmithi]
2- Place the dead body on its right side facing the Qiblah, supporting its backside with unburnt bricks and its face on the wall of the grave to be fixed in the same state. The Prophet said: "The Qiblah for dead and alive Muslims." [Al-Bayhaqi and Abu Dawood, and al-Sayooti classified it as a sound Hadeeth]. Place the legs of the dead body in first is better, if possible, and repeat the Prophetic Hadeeth: "In the name of Allah and on the religion of Allah's Messenger." [At-Tirmithi]
3- Avoid tearing the shroud since such a work will destroy it. Only it is desirable to untie it from the two ends. The Prophet said: "When one amongst you shrouds his brother, then let him should him well." [Muslim]
According to Al-Bayhaqi, when Nu'aym Ibn Mas'ood was buried, the shroud was untied from the side of the mouth.
4- Put unburnt bricks on Lahd to prevent soil from reaching the dead's face. It is disliked to use wood and burnt bricks. Then, we pour soil on the grave. It is Sunnah for those who take part in the burial to throw three hand's full of soil on the grave.
5- Raise the grave one span of the hand above the ground to make the grave known; making it as a hump is better than being flat for the saying of Sufyan who saw the Prophet, 's grave in the same form as reported by Al-Bukhari . So, the grave should not be raised more for the Prophetic sound Hadeeth from Abu Al-Hiyyaaj who said that ‘Ali told him: “Should I not instruct you to do as the Messenger instructed me? Do not leave a statue standing without removing it. Do not leave a grave raised without leveling it.”
Another narration from al-Qaasim Ibn Muhammad reads “I said to ‘Aa’ishah: “Mother, show me the grave of the Prophet and his two Companions . She showed me three graves which were neither high nor low but were spread with soft red pebbles in an open space.
Then, it is desirable to shower the grave with water as mentioned in a Hadeeth narrated by Abu Raafi’i and reported by Ibn Maajah. Another narration from Jabir supports the above opinion (about spraying the grave).
6- Building on the grave is disliked. Also, it is disliked to plaster the grave, or decorate it, or write on it. Even if one's will before his death contains such things, it should not be fulfilled.
Thus, all buildings over the graves are to be destroyed unless such an action causes what is worse. As for writing the Quran or the deceased's name on the grave, it is disliked according to the opinion of the majority of the scholars.
Jaabir narrated that the Prophet forbade to plaster the grave, to build over it, to sit on it, or to write on it."
It is allowed to put a sign to mark the grave by using a stone or something like that, as the Prophet put some pebbles to recognize the grave of his son Ibrahim. He also put a rock at the head of Ibn Math’oon's grave so that we can bury new dead relatives.
As for the size and depth of the grave, then this differs from one person to another and from one place to another. What is important is to bury the dead body to be safe from beasts of prey and prevent the spreading of a bad smell.
As for your question "What should we do after 40 days"; then nothing is confirmed in this regard with the exception of supplicating for him, seeking Allah's forgiveness for him, giving charity on his behalf (i.e. while intending the reward for the deceased), and keeping good relation with the deceased's friends. Then, to fulfill the deceased's will.
For more benefit on washing the dead, please refer to Fataawa 394099, 84697, 98808, and 146943.
Allah knows best.