Hijab is often thought of as a women's matter, but in the Quran the command about modesty comes to men first: lower your gaze and guard your private parts, that is purer for you. Men are told, like women, to wear fine clothing to the mosque without waste, and the Quran speaks of the clothing of piety as the best clothing. Modesty for men is therefore a matter of both behaviour and dress.
The Prophet Muhammad ﷺ said that none of you should pray in a single garment with nothing on his shoulders. He taught men not to drag their garments in arrogance, and said that Allah will not look on the Day of Resurrection at the one who trails his garment out of pride. Men are forbidden to wear gold, as when the Prophet ﷺ forbade gold rings, and pure silk: when Ali wore a silk robe that the Prophet ﷺ had given him and saw anger on the Prophet's face, he cut it up among the women of his household.
Most scholars hold that a man's private area, which he must keep covered in front of others, runs from the navel to the knees. A minority view, including a view in the Maliki school, is more lenient about the thighs. The cap and the long shirt that many Muslim men wear are local customs and not a uniform, and scholars differ on whether growing the beard is a duty or strongly recommended. What the rules share is a single principle: humility, cleanliness and modesty, for men as for women.