Long-term capital gains are the profits made when you have sold an asset that you have held for at least a year. Since 1921, they have been taxed at a preferential rate to short-term capital gains, which are taxed at the same rate as your ordinary income. The thinking generally has been that taxing long-term capital gains at lower rates than income encourages longer-term investment.  Read on to find out more about how capital gains are calculated and taxed, and how they can be used to your advantage.

Calculating long-term capital gains
The process for calculating long-term capital gains is simple yet can get complicated for some types of assets. A capital gain or loss is the difference between the cost basis and what you sold the asset for. You must have held the asset for at least a year, otherwise it is a short-term capital gain and is taxed at the same rate as your ordinary income.

Cost basis is the price paid for an asset, but this can be affected by various items. For stocks, calculating your cost basis is relatively simple; however, your cost basis is adjusted for stock splits, dividends paid in stock, mergers, and spinoffs. While this sounds complicated, brokerage statements now include cost basis information on your 1099-B.

If you received the asset as a gift or inheritance, the rules for your cost basis, which you can read about here, are slightly more complicated. Calculating cost basis for mutual funds has its own quirks, which are covered here, while taxation of MLPs is complicated and is covered here.

Federal long-term capital gains taxes
As the U.S. has a progressive tax system, the long-term capital gains rate is based on the tax bracket you fall into.

Tax Bracket

Long-Term Capital Gains Rate

10%-15%

0%

25%-35%

15%

39.6%

20%

Source: IRS.

Additionally, single taxpayers who make more than $200,000 a year, or $250,000 for those taxpayers who are married filing jointly, pay an additional 3.8% on investment income, including capital gains, above a certain level because of the new Medicare contribution tax. If this applies to you, a useful explanation of the new Medicare tax can be found here.

From the above chart you can immediately see the large difference in tax rates between ordinary income and long-term capital gains rates. The 10-to-20 percentage point difference in tax rates can have massive effects on your wealth over time, as short-term traders have to give the government a much larger cut of their income than those who buy and hold. It is one of the reasons that short-term traders habitually underperform long-term investors.

It should be noted that there are some exceptions to the above rules. Most notably, sales of collectibles and precious metals have a higher long-term capital gains tax of 28%.

State long-term capital gains taxes
Investors also need to consider state capital gains taxes. Across the U.S., states levy an average 5.1% tax on long-term capital gains, according to The Tax Foundation. Unlike the federal government, many states do not differentiate between capital gains and other types of income. While nine states have no long-term capital gains tax, the state with the highest long-term capital gains rate is California, at 13.3% for its highest earners. This means a high-income investor in California pays a combined federal and state long-term capital gains rate of 33.3%, which doesn't even include the additional 3.8% Medicare tax! For more on state capital gains tax rates, check out this chart from The Tax Foundation.

Capital loss
A capital loss is the opposite of a capital gain. If you sold an investment that lost you money, you have generated a capital loss. Losses happen; even the world's best investors don't always get their picks right and end up having to deal with losing investments.

In a tax year, you can offset your capital gains with any capital losses. If you end a tax year with a net loss, you can even deduct the loss, up to a maximum of $3,000, from your income. Losses in excess of this amount can be carried forward to future years and as such are called capital loss carryovers. Investors are well advised to consider the benefits of taking losses on losing stock positions, a strategy called tax-loss harvesting, which you can read about here.

How to pay no long-term capital gains taxes
There's one surefire way to avoid paying long-term capital gains taxes, and that is by never selling your investments. Warren Buffett has said that his favorite holding period is forever, and investors would do well to heed that advice. It's not as easy as just buying a few stocks and holding them forever, though. With a horizon of forever, you need to consider not only what price you pay but also whether the business will be able to continuously get stronger over time.