When you sell an asset for more than you paid for it, or specifically for more than your cost basis, the net profit is considered to be a capital gain. For a simplified example, if you spend $5,000 to buy shares of a certain stock and sell your position for $7,000, you'd have a $2,000 capital gain.

The way capital gains are taxed depends on how long the asset was owned for. The time period to keep in mind is one year. If you owned the asset for one year or less before selling it, you would have a short-term capital gain. On the other hand, if you owned the asset for at least a year and a day, it would be considered a long-term capital gain.

Small clock on top of letter blocks spelling tax.

Image source: Getty Images.

The 2020 long-term capital gains tax brackets

Now that you know what a long-term capital gain is, let's take a closer look at how they are taxed.

Short-term capital gains are taxed as ordinary income at your marginal tax rate, or tax bracket. In other words, if you sell a stock after just a few months, any profit will be treated no differently than income from your job, as far as federal income tax is concerned.

On the other hand, long-term capital gains get favorable tax treatment. They are taxed at rates of 0%, 15%, or 20%, depending on the investor's taxable income, but these rates are generally lower than the corresponding tax brackets for all income levels.

Long-Term Capital Gains Tax Rate

Single Filers (Taxable Income)

Married Filing Jointly

Heads of Household

Married Filing Separately

0%

$0-$40,000

$0-$80,000

$0-$53,600

$0-$40,000

15%

$40,000-$441,450

$80,000-$496,600

$53,600-$469,050

$40,000-$248,300

20%

Over $441,550

Over $496,600

Over $469,050

Over $248,300

Data source: IRS.

In addition, certain high-income taxpayers are required to pay an additional 3.8% net investment income surtax, regardless of whether their gains are short- or long-term.

It's also worth mentioning that qualified dividends also get taxed at these preferential rates. This includes most stock dividends -- REITs and foreign stocks are two common exceptions -- and is subject to a minimum holding period requirement.

Real estate is a special case

The tax treatment discussed in the previous section is true for most types of assets, such as stocks, mutual funds, precious metals, collectibles, artwork, and more.

One special case that you should know about is real estate. And there are two special rules to know about capital gains on real estate assets.

First, if the real estate you sell if your primary home, you might be able to exclude the gains on a profitable sale from taxation. Single homeowners can exclude as much as $250,000 in capital gains from the sale of their primary home, and married couples filing jointly can exclude as much as $500,000. So if you bought your house for $300,000 and sold it for $400,000, you wouldn't have to pay tax on the $100,000 capital gain.

Second, for investment properties, you not only have to pay capital gains on the net profit from a sale, but any cumulative depreciation benefit you're received during your ownership period is considered a taxable gain upon the sale. This is known as depreciation recapture, and while the rules (and the ways you can avoid this tax) are beyond the scope of this article, be aware that there could be major capital gains tax implications if you sell an investment property.

An example of long-term capital gains tax

Here's an example of how this works. Let's say that you and your spouse have combined taxable income (excluding investment income) of $100,000. You bought a stock in September 2018 for a total of $4,000 and sold it in January 2020 for $6,000. This gives you a $2,000 capital gain, and because you owned the stock for more than a year, you can treat it as a long-term capital gain. Based on the capital gains tax brackets listed earlier, you'll pay a 15% rate, so the gain will add $300 to your tax bill for 2020.

It's also worth noting that if you're on the cusp of one of the brackets, not all of your capital gains will necessarily be taxable at the same rate. For example, if you're single with $38,000 in taxable income and a $5,000 capital gain, the first $2,000 will be tax-free (0% rate), but the part that brings your taxable income above the $40,000 threshold for the 15% bracket will be taxed at that rate.

Think twice before selling investments too quickly

The U.S. tax code is designed to encourage long-term investments, which is why gains on long-held assets get favorable tax treatment. While there are certainly several things you should consider before deciding when to sell an investment, it's important to think twice before selling an investment for a profit, especially if you've held it for close to (but not quite) a year.