Simply put, you can afford a house that costs as much as the largest monthly mortgage payment you qualify for.
A quick way to estimate the size of mortgage you qualify for is to take your gross monthly income (that’s before taxes and other deductions) and multiply it by .28. This works out to just over 1/4 of your gross income.
Mortgage companies use something called qualifying ratios to determine how much they’ll lend you. Most mortgage companies use either a 28/36 ratio or a 25/33 ratio. The first number in each pair is the percentage of your gross income that the lender would consider acceptable as a monthly mortgage payment (i.e. if you make $3,000 per month, 28% of that is $840 per month).
The second number in each pair is used when all debt payments are considered, not just the mortgage. (i.e. if you make $3,000 per month, but also have a $250 a month car payment, 36% of $3,000 is $1,080, minus the $250 car payment equals $830).
As you can see, in this example the numbers work out to be almost the same. Obviously if you have more debt you would qualify for less.