Firstly: The Ruling of Offering Condolences  Offering condolences is giving reason for patience and solace for the deceased’s relatives, lightening their sadness and taking away from their burdensome calamity. It is established through any means and devices, whether through social media, by phone, and its like; except if they are close by relatives, in which case, visiting in person is necessary. As for offering condolences in newspapers and magazines, then this should be avoided, as it is a waste of abundant amounts of money. There are scholars who view this as a prohibited form of consolation. to the Muslim
Offering condolences is mustahabb.  From the habits which have no legal origin are gatherings where Qur’an is recited, especially al-Fatihah. Also, the procurement of reciters with a wage or without to recite while visitors arrive and are served food. This is by agreement of the four schools of jurisprudence.
Secondly: Repeating Condolences
It is makruh to repeatedly offer condolences. This is explicitly mentioned by Hanafis and Hanbalis.
Thirdly: The Ruling of Offering Condolences to a Disbeliever
It is permissible for a Muslim to offer his condolences to a disbeliever, as well as a legally contracted disbeliever.  Some scholars excepted the warring and the apostate. These two are not offered condolences, unless if it is hoped they are softened to Islam through this. This is the position of the majority: Hanafis, Malikis, Shafi`is,  It is mustahabb for them to give him condolences if it is hoped he is to accept Islam. and a narration from Ahmad.
Fourthly: The One to Whom Condolences are Offered
It is mustahabb that all the deceased's relatives  There are scholars who view it as mustahabb to offer condolences all affected by the loss of the deceased, like friends and neighbours. are offered condolences, the young and old, men and women, except the young woman, then only her family members may offer her their condolences. This is by agreement of the four schools of jurisprudence.
Fifthly: Utterances of Condolences
There are no specific words or utterances that should be said when offering condolences, rather the Muslim offers his condolences to his brother using words that achieve the required outcome.  These are some statements which jurists have mentioned for offering condolences: “To Allah what He has taken, and to Him is what He gives, and everything to Him is to a named accord;” “May Allah follow your loss with righteousness, as He has followed up His righteous slaves;” “May Allah make great your reward, grant you solace, and forgive your deceased;” and the like of that. If the deceased is a disbeliever and the consoled a Muslim, then the Muslim says: “May Allah make great your reward, and grant you solace.” If the deceased is a Muslim and the consoled a disbeliever, then the Muslim says: “May Allah grant you solace, and forgive your deceased.” If the deceased is a disbeliever and the consoled a disbeliever, then the Muslim says: “May Allah replace you with goodness.”
Sixthly: The Time of Consolation
Scholars have differed over the latest time of offering condolences according to two views:
The first: is that it is from the moment of death until burial, then after burial for three days.  Unless if the consoled is absent or the one consoling, and they did not meet. In this case, there is no problem if he consoles him after three days. This is by agreement of the four schools of jurisprudence.
The second: is that there is no specified time limit for consoling the deceased's family. This is a position among Shafi`is, the position of some Hanbalis, as well as the position of Ibn Taymiyyah, Ibn Baz, Ibn `Uthaymin, and al-Albani.
Seventhly: Sitting for Condolences
Scholars have differed over the ruling of sitting for condolences according to two views:
The first: is that it is not legislated. This is the position of the Shafi`is, Hanbalis, a position among Hanafis, a position among Malikis, and the choice of Ibn `Uthaymin and al-Albani.
The second is that it is permissible. This is a position among Hanafis, a narration from Ahmad, and it is the choice of Ibn Hajar and Ibn Baz.