New York CNN Business  — 

The stock market is a mess right now, but here’s some Wall Street wisdom for these tough times: Eat, drink and be merry. Emphasis on the merry if you’ve been buying food and beverage stocks.

Stodgy consumer staples companies like food and drink makers tend to do well even during economic rough patches and market turmoil. That’s because even if people cut back on discretionary spending like going out to restaurants or streaming video subscriptions, they still have to eat and it’s cheaper to do so at home.

So investors are betting on food and beverage makers at this time of high inflation and economic angst — and that was very clear Monday, with several food stocks rising even as the broader market tanked again.

Shares of Campbell Soup (CPB), ConAgra (CAG), Kellogg (K), General Mills (GIS), Kraft Heinz (KHC), Smucker (SJM), Tyson Foods (TSN) and spice maker McCormick (MKC) gained on Monday. All of these stocks are in the green for the year too. Meanwhile, Coca-Cola (KO) and Hershey (HSY) are also enjoying solid gains and both stocks are not far from record highs.

It’s not just the necessity factor: Inflation is also lifting the fortunes and outlooks for many food companies. Tyson Foods, for example, reported better than expected earnings and sales and healthy guidance Monday in part due to rising retail prices for beef and chicken.

Tyson chief financial officer Stewart Glendinning said on a conference call with analysts that so far, “consumer demand has remained durable even as we worked to manage inflation through price increases” and that “category relevance has enabled continuing strong demand” even though prices have gone up. In other words: People are still eating animal protein and they’re willing to pay up for it.

Coca-Cola, Kellogg and Kraft Heinz have all reported solid earnings in the past few weeks as well.

According to data from FactSet Research, the consumer staples sector has had the highest percentage of companies reporting results for the first quarter that topped forecasts, led by big earnings beats from frozen french fries maker Lamb Weston (LW), Molson Coors (TAP) and agricultural products and flavors giant Archer-Daniels-Midland (ADM).

Another factor that makes these stocks attractive to investors is that many food and beverage companies pay steady dividends with relatively high yields. That also makes them a potential option for conservative investors, even as long-term bond yields have shot up due to inflation fears.

Kellogg has a dividend that yields 3.2%, roughly in line with the rate on the 10-year Treasury bond. Coke and its rival Pepsi (PEP) have dividends that yield near 3% too, along with Oreo maker Mondelez (MDLZ).