Hector Ramirez sort of knows, from watching old movies, that men are supposed to take off their hats when indoors. But the 19-year-old Brown University student wears fedoras in class—with jeans—anyway.

"If I'm wearing a hat and it's part of my look, I don't think I should have to take it off," he says. On a recent trip to New York, an usher at a church had to remind him to take off his fedora. "I was wearing it all day and I guess I kind of just forgot I had it on."

Inspired by designer runway shows, celebrities such as Justin Timberlake and even, in some cases, old pictures of Frank Sinatra, more young men are going mad for hats. But the hat renaissance is creating a quandary for a generation of men and boys who grew up without learning hat-wearing etiquette from their fathers. Many are making up their own rules about when and where to take them off.

The trend may be old hat to hipsters in areas like Williamsburg, Brooklyn, who started wearing fedoras, rounded derby hats and, in warmer weather, straw hats, more than two years ago. But now hats are starting to catch on among some men in suburbs, the Midwest and beyond. Gap and J. Crew say they have witnessed strong hat sales this spring and summer while department stores like Barneys New York have been expanding their assortments after years of general indifference to hats. Sales of designer-brand "blocked" hats such as fedoras and straw hats in particular "are definitely robust," says Jay Bell, a vice president at Barneys.