I have seen and heard a number of times the question asked - always with an actual or implied malicious grin - whether one is allowed to wear a fedora hat on Shabbos. The issue is as follows:
The Gemara in Eruvin (102b) relates:
Rav Shisha the son of Rav Idi said: "[Wearing] a felt hat [on Shabbos] is permissible." But is it not taught that it is prohibited? This is not difficult. This [teaching] is when it has a tefah and this [teaching] is when it does not have a tefah. If so, wearing a tallis on one's head that extends a tefah should be prohibited. This is not difficult. One is when it is tightly fastened [on one's head] and one is when it is not tightly fastened.Rashi explains that the Gemara initially suggested that wearing a hat on Shabbos is potentially problematic because the brim creates a tent that protects one's face. By putting on the hat, one is creating a tent [in a rabbinically prohibited fashion]. However, the conclusion of the Gemara is that this is not creating a tend and the real reason for prohibiting the wearing of a hat on Shabbos is that it might be blown off and one would pick it up and carry it on Shabbos. Rabbenu Hananel, quoted by Tosafos, explains the Gemara as concluding that hats do create a tent. However, only when a hat is fastened tightly to one's head and the brim is very stiff does it look like a tent and is therefore prohibited.
The Shulhan Arukh (301:40) rules like Rabbenu Hananel that wearing a hat with a brim wider than a tefah (about 4 inches) is prohibited because it is a tent. However, in the next paragraph, the Shulhan Arukh adds Rashi's explanation as a "some say," implying that one should also be strict for Rashi's view and not wear a hat that is intended as shade unless it is tightly fastened to one's head, because the hat might be blown off.
Based on this, it seems fairly clear that one may not wear a fedora on Shabbos if the hat's brim is wider than a tefah. Does this seem to indicate that the entire "black hat" world is violating Shabbos every single week? Did, for example, the late Lubavitcher Rebbe violate Shabbos every week? Or R. Joseph B. Soloveitchik?
Before anyone asks this question, it might be appropriate for him to look in the commentaries on the Shulhan Arukh. Were he to do this, he would see that the question was raised some seven centuries ago and ably settled then. The Magen Avraham quotes authorities who rule that the only problem is if the brim is hard (unlike most Borsalinos, for example) and, even then, if the brim is tilted downwards then there is no problem. The Taz also points out that the problem only arises if the hat is worn in order to be a tent, i.e. to shade one's face. If not, then there is no problem at all.
These positions have been upheld by all the subsequent commentaries to Shulhan Arukh, continuing to recent times. See, for example, the Arukh Ha-Shulhan and the Mishnah Berurah. Notably, the Shulhan Arukh Ha-Rav, written by the first Lubavitcher Rebbe, also follows these rulings.
R. Eliezer Yehudah Waldenberg, in his Tzitz Eliezer (10:23), writes at length to answer this question and also points out that if such a large portion of the observant world, including great halakhists and talmudic scholars, follow a practice, then one should assume that it has solid basis and is not a violation of a prohibition.