Carl
Level 15

Investors & landlords

In the year you sell, rental losses are not restricted to the passive rental income, and are taken against what is referred to as "ordinary income", with any gains on the sale being reduced by those losses first.
For some more detail, in the year you sell all prior depreciation is recaptured and taxed in that year of sale. It's taxed no matter what and there's no way out of it unless you sell at a loss. So if you do sell at a gain that depreciation recapture has the potential to increase your taxable gain even more. However, even if you qualify for the "lived in two of last five years" capital gains tax exclusion, you will still be taxed on the recaptured depreciation. There's just no way out of that when the property is sold at a gain.
Many times when people are selling rental property and they're selling for a bit less than they paid for it, they're shocked when they see a taxable gain. That's the tax on all that recaptured depreciation kicking in. Here's an extremely rough example using just basic numbers. (Not all inclusive, just making the point here.)
 - Purchased property in 2001 for $80,000.
 - Rented it out since purchase over the last 17 years and in 2017 have a total accumulated depreciation of $43,000.
 - In 2018 sold the property for $60,000. I have a $23,000 taxable gain.
That's because the $43K of depreciation reduces my original cost basis of $80,000, to $37,000. So selling for $60,000 gives me a taxable gain of $23K. I'm paying taxes on that $23K weather I like it or not. If that recaptured depreciation puts me in a higher tax bracket, then I'm also paying a higher tax rate on *all* of my taxable income from all sources.