A capital gain is the profit realized when you sell a capital asset — stocks, bonds, real estate, cryptocurrency, collectibles, or other investments — for more than its cost basis (what you originally paid, including transaction costs). Capital gains are only "realized" — and only become taxable — at the moment of sale. Until then, gains are "unrealized" or "paper gains," and no tax is owed regardless of how much an asset has appreciated. This distinction between realized and unrealized gains is one of the most powerful features of long-term investing: you can compound returns on an asset for decades before the IRS takes its share.

The US tax code distinguishes sharply between short-term capital gains (assets held 1 year or less) and long-term capital gains (held more than 1 year). Short-term gains are taxed as ordinary income — at the same rates as your wages (10%–37%). Long-term gains receive preferential tax treatment at 0%, 15%, or 20%, depending on taxable income. In 2024, single filers pay 0% on long-term gains up to $47,025 in taxable income, and 15% up to $518,900. For most middle-income investors, this means long-term gains are taxed at 15% — less than half the ordinary income rate many face. Holding any investment just one day past the one-year mark can mean paying half the tax.

Cost basis — the purchase price used to calculate gains — requires careful tracking. If you buy 100 shares at $50 and later sell 50 shares at $80, your gain is 50 × ($80 − $50) = $1,500. But if you made multiple purchases at different prices, you can choose which "lot" to sell using specific lot identification — a significant lever for minimizing taxes. Selling your highest-cost-basis shares first reduces your taxable gain on that transaction. Failing to track cost basis (or accepting a broker's default FIFO — First In, First Out — method) can result in unnecessarily high tax bills.

Tax-loss harvesting is the practice of deliberately selling positions that have declined in value to realize capital losses, which can be used to offset capital gains. Up to $3,000 of net capital losses can be deducted against ordinary income annually; excess losses carry forward indefinitely. For example: if you have $12,000 in realized gains and harvest $8,000 in losses, your taxable gains drop to $4,000 — saving $600–$1,600 in taxes depending on your bracket. The key constraint: the wash-sale rule prohibits repurchasing the same (or substantially identical) security within 30 days before or after the sale, which would disallow the loss. You can immediately buy a similar (but not identical) security to maintain market exposure.

Two major capital gains exclusions deserve special attention. The primary residence exclusion allows homeowners to exclude up to $250,000 ($500,000 for married couples filing jointly) of capital gain on the sale of a primary home, provided they have owned and lived in it for at least 2 of the past 5 years. A married couple who bought a home for $400,000 and sells for $900,000 owes zero capital gains tax on the $500,000 gain. The step-up in basis rule for inherited assets is equally powerful: when you inherit an asset, your cost basis "steps up" to the fair market value at the date of the decedent's death, eliminating all accumulated gains from the decedent's lifetime. Inheriting stock worth $200,000 that your parent bought for $20,000 means you could immediately sell it for $200,000 with zero capital gains tax.

The intersection of capital gains strategy with account type is critical for tax-efficient investing. In tax-advantaged accounts (401k, IRA, Roth IRA), capital gains are either tax-deferred (traditional) or never taxed (Roth) — so asset location matters. Hold high-appreciation assets (growth stocks, REITs) in Roth accounts where gains are permanently tax-free. Hold income-generating assets (bonds, dividend stocks) in traditional tax-deferred accounts. Keep tax-efficient funds (index ETFs with low turnover) in taxable accounts. In taxable brokerage accounts, favor buy-and-hold index investing to minimize annual taxable distributions, and apply tax-loss harvesting systematically during market downturns.