Dividend stocks have an advantage over peers in that they deliver income on top of any potential capital gains. But while that immediate cash flow is comforting, life-changing returns accrue over longer periods (think decades, not quarters). That kind of patience gives you the best odds at beating the market and allows dividend income to compound itself through automatic reinvestments.

The trick is finding the right stocks to hold through the economic ups and downs.

While no business is perfect, a few stocks have proven they can thrive through almost any selling environment while boosting dividend payouts. Let's look at why Procter & Gamble (NYSE:PG), McDonald's (NYSE:MCD), and Sherwin-Williams (NYSE:SHW) are just the type of investments you can feel comfortable owning over the long term.

Stacks of coins showing growth from left to right.

Image source: Getty Images.

1. Procter & Gamble

Procter & Gamble has the type of business that's nearly impossible to rattle. The company dominates the global market for dozens of essentials that consumers use each day. Over 25% of laundry sales go to its Tide, Ariel, and Downy brands, for example, and 40% of U.S. paper towel sales belong to Bounty.

That premium selling posture creates a steady sales and profit base, which helps explain why P&G has raised its dividend for more than 60 consecutive years. It generates market-thumping financial results, too, with cash flow, profitability, and earnings metrics all routinely beating peers like Kimberly Clark (NYSE:KMB).

Wall Street has soured on P&G stock in the wake of the pandemic as investors chase more aggressive growth categories. But that sentiment shift means you can get a higher dividend yield (over 2% in early July) by purchasing shares right now.

2. McDonald's

The fast-food industry is highly competitive and characterized by tiny profit margins for even the most enduring brands. But McDonald's isn't playing that difficult game.

Food sales make up a small proportion of its business, which is powered by franchise fees, royalties, and real estate income. This setup allows the chain to enjoy much higher profit margins, with operating income landing near 45% of sales compared to less than 10% for Chipotle Mexican Grill.

McDonald's still needs to innovate to maintain its industry lead. That's another area where the business shines. It pivoted its menu and operations in response to several major consumer demand shifts in recent years, including a push toward healthier food and more convenient delivery options. The result has been a trend of steadily rising customer traffic that was only briefly interrupted during the pandemic. This flexibility should serve investors well as McDonald's approaches its 50th year of consecutive annual dividend raises.

3. Sherwin-Williams

Watching paint dry is famously boring. Owning shares of the leading paint retailer isn't.

Sherwin-Williams has been a fantastically profitable business for shareholders in recent years. The stock jumped nearly 900% since mid-2011, in fact. Add dividend payments to that mix and you have a nearly 1,000% return in 10 years compared to 300% for the S&P 500.

Chart showing upward trend for S&P 500 and Sherwin-Williams stock.

^SPX data by YCharts

Sherwin-Williams checks all the important investing boxes. It maintains dominant market share in an attractive, growing industry. It has a proven ability to raise prices at a higher rate than inflation, and a proven ability to boost dividends through any kind of market.

Its management team has shown a knack for effective capital allocation, too, whether it's through stock repurchases, debt financing, or large acquisitions like the Valspar merger. That strategic asset should help keep returns rising even after the current boom times end.

But there's no sign of that slowdown yet. Sales jumped 12% in the most recent quarter. Executives are predicting even faster gains when Sherwin-Williams reports Q2 earnings in late July.

This article represents the opinion of the writer, who may disagree with the “official” recommendation position of a Motley Fool premium advisory service. We’re motley! Questioning an investing thesis -- even one of our own -- helps us all think critically about investing and make decisions that help us become smarter, happier, and richer.