According to data provided by real-estate brokerage Redfin, housing prices in the U.S. in December jumped 15.2% year over year, continuing a trend sparked by the pandemic. Homebuyers looking to relocate due to the popularity of remote work, coupled with a tight housing supply and low mortgage rates, are the main causes. 

How can investors play this trend? I think the home-improvement industry's massive brick-and-mortar retailers look intriguing. Here's why Home Depot (HD -1.44%) and Lowe's (LOW -0.88%) are two top stocks to look at in light of the current housing environment. 

Shopper looking at wood inside a hardware store.

Image source: Getty Images.

Home Depot and Lowe's benefit from the soaring cost of living 

"The customers' mindset regarding their home is very straightforward," explained Lowe's CEO Marvin Ellison during the company's fiscal 2021 Q2 earnings call. "As long as their home is increasing in value, they see upgrades and enhancements to their home as an investment and not an expense." This certainly helps the home-improvement industry. 

People spent more time than ever at home during the pandemic, resulting in a renewed focus on renovation projects. Both Home Depot and Lowe's were posting quarterly sales growth in excess of 20% during the depths of the pandemic. At first, demand was driven by DIY customers, who felt uncomfortable allowing strangers into their homes for health and safety reasons. 

But lately, professionals, including contractors, electricians, and plumbers, are boosting revenue numbers. People are starting to take on larger and more complex projects, requiring the help of an expert. For Home Depot, these high-value customers account for 45% of overall revenue. Lowe's is quickly making strides in this area, generating 25% of business from professionals. 

As Ellison mentioned, a robust housing market benefits these companies because it encourages consumers to invest in their homes. Furthermore, this situation is usually indicative of a strong economy, with low unemployment and growing wages. People are more inclined to consider moving when this happens. 

Even in recessionary times, these businesses should do well. During the Great Recession of 2008-09, both Home Depot and Lowe's only registered single-digit year-over-year sales declines. However, it's worth keeping in mind that this economic downturn was caused by an overextended housing market, significantly impacting the entire industry. 

Rising home prices show no signs of letting up this year, boding well for Home Depot's and Lowe's prospects in 2022. 

Valuations aren't inflated

Investors can buy shares in these companies at undemanding valuations. As of Jan. 25, Home Depot's stock traded at a price-to-earnings (P/E) ratio of 24 compared to Lowe's at 20. These are meaningful discounts when considering that the S&P 500 carries a P/E ratio of 27. 

From fiscal 2016 through 2021, Home Depot increased earnings per share at a compound annual growth rate (CAGR) of 16.9%. During the same time period, earnings per share for Lowe's grew more rapidly, at a 23.2% CAGR. For the scale of these companies, that's extremely impressive, and it makes the valuation multiples look even more attractive. And because they both essentially serve the massive housing market, there is still a long runway for expansion ahead. 

There are many ways to bet on rising home prices, like investing in residential-focused real estate investment trusts (REITs), homebuilders, or brokerages. But I think owning Home Depot and Lowe's, with their long operating histories and relatively safe business models, is a solid way to play the current housing market.