There is a cooling off in the housing market.

Many cities in the U.S. are not easy to afford. The average American would have to devote 40% of their income to buy a home in 42 of the 100 cities.

The index takes into account median household income, median for-sale prices and local property taxes. The mortgage expenses are assumed to be a 30 year mortgage, 5.5% interest rate and 20% down payment.

Here are the 12 least affordable housing markets in the US, as well as the median household income, the median home price and the percentage of income required to afford homeownership in each place.

The share of income for the household was 87.39 percent.

The share of income for the household was 85.3%.

The median household income was $68,129, and the home price was $925,000.

The median household income is $38,854 and the home price is $385,000.

The median household income is $40,000, the median home price is $465,000, and the median share of income is 74.5%.

The share of income for the household was 69.7%.

The average household income is $126,117 and the median home price is $1,388,000.

The share of income is 65.65%.

The median household income is $80,000 and the median home price is $834,250.

The median household income was $74,185, and the home price was $750,000.

The share of income is 60.85%.

  • Median household income: $79,797
  • Median home price: $775,000
  • Share of income: 59.38%

In order to be a homeowner, an average family in Miami, Los Angeles or New York would have to devote 80% of their income to housing. It is likely that the remaining 20% will not be enough to cover all expenses.

The judge on CNBC's "Money Court" advises potential homeowners to follow the 13 rule when purchasing a home. Only 13 of your income should go towards your home. The rule states that anyone earning the median income in any of the places above would be outside of it.

If you rent or buy a smaller home, you will have to live in a smaller apartment.

The advice first issued by the U.S. government in 1981 states that you should spend no more than 30% of your income on housing costs.

You can get smarter about your money and career by signing up for our weekly newsletter.

The job market is getting worse.