Golf hats are usually not specified in a dress code, but certain head wear is more appropriate than others. Baseball-style hats or visors seem to be the most popular ones worn on the golf course by both men and women. The primary purpose of the hat is to help provide protection from the sun. Straw hats of many varieties and what are known as Ben Hogan caps are also permitted. However, cowboy hats, dress fedora-style hats, and gag hats would not be allowed on a private or semi-private golf course.
Way back before the baseball type golf hats were invented, the traditional Scottish golfers would wear a cap like the one on the left hand side, partly because of the cooler weather, so the hat also served to keep the golfer’s head warm. I play with a couple of older scottish golfers who still wear hats like this one today, in keeping with tradition.
There are a wide variety of hats from different manufacturers. Check out this link to see if you find a golf hat that you like.