While you own a rental you deduct depreciation (27.5 years for US residential buildings; see the depreciation calculator). When you sell, the IRS “recaptures” that benefit: the part of your gain equal to depreciation taken (or allowable) is unrecaptured Section 1250 gain, taxed at your ordinary rate up to a maximum of 25%. The rest of the gain is a regular long-term capital gain.
Example
Bought for $250,000 (building $200,000), held 10 years, depreciation ≈ $72,700. Sold for $350,000: adjusted basis ≈ $177,300, total gain ≈ $172,700, of which $72,700 is recapture (up to 25%) and $100,000 is capital gain (0/15/20%), plus possible 3.8% NIIT.
Deferring it
A 1031 exchange defers both recapture and capital gain. Holding until death can eliminate them via a stepped-up basis under current law. This is general information — consult a tax professional.