Summary: Selling an investment can trigger capital gains taxes, but the amount owed depends on factors like holding period, cost basis, and your overall income. Long-term gains are taxed at preferential rates (0%, 15%, or 20%), while short-term gains are taxed as ordinary income. Strategies like tax-loss harvesting, choosing the right cost basis method, and understanding the Net Investment Income Tax can help minimize your tax bill.
Deciding to sell an investment is rarely a simple decision. Beyond the emotional weight of exiting a position or the logistical challenge of rebalancing a portfolio, there is a critical financial question: how much of that gain will you keep? The tax consequences of a sale can significantly erode your net return if you haven’t planned for them. Understanding the tax rules that apply to investment sales can help you make more informed decisions and potentially save thousands of dollars.
Capital Gains Tax Basics
When you sell an asset for more than its adjusted cost basis—generally what you paid for it, plus certain adjustments—you realize a capital gain, which is subject to tax . The rate you pay depends on how long you held the asset before selling it.
Short-Term vs. Long-Term Gains
The holding period is the most critical factor in determining your capital gains tax rate .
- Short-term capital gains apply to assets you held for one year or less. These gains are taxed at your ordinary income tax rates, which can be as high as 37% for top earners in 2026 . This makes short-term trading potentially expensive from a tax perspective.
- Long-term capital gains apply to assets you held for more than one year. These gains benefit from preferential tax rates of 0%, 15%, or 20%, depending on your taxable income and filing status . For 2026, the 0% rate applies to single filers with taxable income up to $49,450 and married couples filing jointly up to $98,900. The 20% rate applies to single filers with income over $545,500 and married couples over $613,700 .
The One Big Beautiful Bill Act (OBBBA) made several tax provisions permanent, including the higher standard deduction—$16,100 for single filers and $32,200 for married couples in 2026—which can help keep more taxpayers in the 0% capital gains bracket .
Understanding Cost Basis
Your cost basis is the original value of an asset for tax purposes, usually the purchase price plus commissions and adjustments. Accurately tracking your cost basis is essential because it determines the size of your taxable gain or loss when you sell .

What Can Adjust Your Cost Basis?
Several events can change your cost basis :
- Reinvested dividends: When you reinvest dividends, the reinvested amount is added to your cost basis. If you don’t track this, you could end up paying tax on the same income twice.
- Stock splits: Your cost basis per share is adjusted proportionally in a stock split.
- Return of capital: Some investments, like certain REITs, may distribute return of capital, which reduces your cost basis and is not taxed as ordinary income.
Choosing a Cost Basis Method
When you sell shares, you need to determine which shares you’re selling. Your brokerage may offer several methods for calculating cost basis :
- Specific Identification: You manually select which shares to sell, giving you the most control over the tax outcome.
- FIFO (First In, First Out): The oldest shares are sold first. This can help limit short-term gains but may result in higher overall gains if your oldest shares have the lowest cost basis.
- LIFO (Last In, First Out): The most recently purchased shares are sold first. This can result in a higher cost basis and lower gains in a rising market, but may generate short-term gains.
- High-Cost Lot: Shares with the highest cost basis are sold first, minimizing capital gains.
- Low-Cost Lot: Shares with the lowest cost basis are sold first, maximizing capital gains.
The method you choose can significantly affect your tax liability, so it’s worth reviewing your options before executing a sale .
Net Investment Income Tax (NIIT)
High-income investors may face an additional 3.8% tax on their net investment income. The NIIT applies to single filers with a modified adjusted gross income (MAGI) over $200,000 and married couples filing jointly over $250,000 . It applies to the lesser of your net investment income or the amount by which your MAGI exceeds the threshold .
For example, a married couple filing jointly with $300,000 of MAGI and $40,000 of net investment income would pay 3.8% on $40,000—a $1,520 tax—because their MAGI exceeds the threshold by $50,000 . The NIIT can apply to interest, dividends, capital gains, rental income, and passive business income .
Tax-Loss Harvesting
Tax-loss harvesting is a strategy that involves selling investments that have lost value to realize a capital loss. The loss can then be used to offset capital gains elsewhere in your portfolio, and if your losses exceed your gains, you can use up to $3,000 to offset ordinary income per year .
For example, if you have realized $10,000 in capital gains and sell another holding at a $7,000 loss, your taxable gain falls to $3,000 . Any unused losses can be carried forward indefinitely . This strategy applies only to taxable brokerage accounts—you cannot harvest losses in IRAs or 401(k)s .
The Wash-Sale Rule
A critical pitfall to avoid is the wash-sale rule. The IRS disallows a loss deduction if you buy a “substantially identical” security within 30 days before or after the sale that produced the loss—a 61-day window . The disallowed loss is not lost; it is added to the cost basis of the replacement shares, deferring the deduction rather than eliminating it .

The rule applies across all accounts you control, including IRAs, and even to your spouse’s accounts . For example, selling a stock at a loss in your taxable account and buying it in your IRA within 30 days would trigger the wash-sale rule . To avoid this, you can wait 31 days to repurchase the security or buy a similar but not “substantially identical” investment .
Dividend Taxation
Dividends are also subject to tax, but the rate depends on whether they are qualified or ordinary .
- Qualified dividends are taxed at the same favorable rates as long-term capital gains: 0%, 15%, or 20% .
- Ordinary dividends are taxed at your regular income tax rates .
To qualify for the lower rate, you generally need to hold the stock unhedged for more than 60 days during a 121-day window that starts 60 days before the ex-dividend date . High-income investors may also owe the 3.8% Net Investment Income Tax on their dividend income .
Frequently Asked Questions
1. What is the capital gains tax rate for 2026?
Long-term capital gains are taxed at 0%, 15%, or 20%, depending on your taxable income and filing status. Short-term gains are taxed at ordinary income rates, which range from 10% to 37% .
2. How do I avoid paying capital gains tax?
You can potentially avoid capital gains tax by holding assets until your taxable income falls within the 0% long-term capital gains bracket, using tax-loss harvesting to offset gains, or donating appreciated securities to charity .
3. What is the wash-sale rule?
The wash-sale rule prevents investors from claiming a loss deduction if they buy a “substantially identical” security within 30 days before or after the sale. The disallowed loss is added to the cost basis of the replacement shares .
4. What is the Net Investment Income Tax and who pays it?
The NIIT is a 3.8% tax on net investment income for individuals with a MAGI over $200,000 (single) or $250,000 (married filing jointly) .
5. How does the Net Investment Income Tax affect investment sales?
Gains from the sale of investments are included in net investment income and may be subject to the 3.8% NIIT if your income exceeds the applicable threshold .
6. What is cost basis and why does it matter?
Cost basis is the original value of an asset for tax purposes, usually the purchase price plus commissions. It determines the size of your taxable gain or loss when you sell .
7. What happens when I reinvest dividends?
Reinvested dividends increase your cost basis. If you don’t track this, you could end up paying tax on the same income twice when you eventually sell the shares .
8. Are dividends taxed differently than capital gains?
Qualified dividends are taxed at the same rates as long-term capital gains, while ordinary dividends are taxed as ordinary income .
9. Can I deduct investment losses?
Yes. Realized losses can offset capital gains, and if losses exceed gains, you can deduct up to $3,000 of net losses against ordinary income per year, with excess losses carried forward indefinitely .
10. Should I use FIFO or specific identification for my cost basis?
Specific identification gives you the most control over your tax outcome, but it’s more manual. FIFO automatically sells your oldest shares first and is the default if you can’t identify specific shares .
The Long View on Investment Sales
Selling an investment is never just a matter of the sale price. The tax implications of a transaction can shape your net return and your overall financial plan. By understanding the rules around capital gains, cost basis, and the NIIT, you can make more informed decisions. A little planning—including reviewing your cost basis method, timing sales to qualify for long-term rates, and harvesting losses—can go a long way in protecting your wealth from unnecessary taxes.

Key Takeaways:
- Long-term gains are taxed at 0%, 15%, or 20%, while short-term gains are taxed as ordinary income .
- Accurately track cost basis, including reinvested dividends and stock splits, to avoid overpaying tax .
- The NIIT adds 3.8% to investment income for high earners above $200,000/$250,000 thresholds .
- Tax-loss harvesting can offset gains and up to $3,000 of ordinary income annually .
- Avoid the wash-sale rule by waiting 31 days to repurchase or buying a similar but not identical security .