As prices for new vehicles continue to rise, the cost of an average new car may be a stretch for typical households.

A new analysis from Bankrate.com found that a median-income household could not afford the average price of a new vehicle in any of the 50 largest cities in the country, though cars are more affordable in some cities than others.

"The new reality is that cars are becoming more expensive," said Steve Pounds, a personal finance analyst for Bankrate. "People are having to make tough decisions about financing."

The average price of a new car or light truck in 2016 is about $34,000, according to Kelley Blue Book. That's in part because new cars are loaded with helpful but expensive safety features like collision-avoidance systems.

Bankrate calculated an "affordable" purchase price for major cities, using median incomes from U.S. census data and factoring in costs for sales taxes and insurance. In San Jose, Calif. — the heart of Silicon Valley — the median income is about $84,000, and an "affordable" new car purchase price is about $33,000 — close to, but still below, the average new car price.

In lower-income cities, however, affordable purchase prices for a typical family are far below the average cost of a new car. In Hartford, Conn., where the median income is about $29,000, an affordable purchase price is about $8,000 — about a quarter of the average new-car price.

That sort of squeeze helps explain why many people are borrowing more, for longer periods of time, to finance a car purchase. Experian Automotive said that in the first quarter of this year, the proportion of new cars bought with the help of financing rose to more than 86 percent, and the average loan amount topped $30,000, which is the highest since Experian began tracking the data. The average term for a new-car loan is now 68 months — about 5½ years — and some loans stretch as long as seven years.

(Auto leases are also becoming more popular because they often offer lower payments than a traditional car loan. With a lease, the customer makes payments for a set period of time, then typically can choose either to return the car to the dealer or to buy it.)

Longer-term loans carry risks. The Consumer Financial Protection Bureau warns that borrowers who take out long-term loans end up paying more for the car overall, and also run a greater risk of owing more than the car is worth.

Bankrate noted that a traditional rule of thumb is the "20/4/10" rule: Car buyers should aim to put down at least 20 percent in cash, take out a loan for no more than four years and keep the cost of principal, interest and insurance to no more than 10 percent of household income.

If you have to abandon those guidelines, the car you want may simply be too expensive.

Ron Montoya, senior consumer advice editor with Edmunds.com, noted that interest rates were still low for new-car loans, but advised shoppers to keep the loan term at no more than five years. Edmunds has an online calculator that you can use to estimate how much you can afford to pay. He also recommends checking the cost of insuring a specific model before buying it, so you won't be shocked when you get your insurance bill after you've made the purchase.

Ann Carrns writes for the New York Times.