If you own property, a business or investments, you are sure to run into the term capital gains, especially when you are figuring out your taxes—and the basic definition is pretty simple. It’s the difference between what you paid for a capital asset and the higher price you eventually sell it for.

But understanding the best ways to minimize capital gains tax can get complicated.

First, a little bit of elaboration. If you have held the asset for at least one year and a day before selling, it’s a long-term gain. If you have held it for a shorter period, it’s a short-term gain. And if the sale price is lower than the purchase price, you have suffered a capital loss, which can be subtracted from capital gains unless it is a wash sale—that is, within 30 days of the sale of the asset you have bought a “substantially identical” asset.

Tax rates: Short-term gains are taxed the same as your ordinary income, based on tax bracket ranging from 10% to 37%. Long-term gains get favorable tax treatment, typically based on three brackets—0%, 15% and 20%.

The zero bracket for long-term gains in 2019 applies for taxable income up to $39,375 for singles and up to $78,750 for joint filers. The 15% bracket for long-term gains applies to taxable income up to $434,550 for singles and $488,850 for joint filers. The 20% bracket for long-term gains applies at higher income levels. The long-term gains brackets for head of household and married filing separately are different and can be found here.

There is an additional 3.8% net investment income tax on modified adjusted gross income over $200,000 for single taxpayers and $250,000 for joint taxpayers.

All qualified dividends are taxed at the same rates as long-term capital gains no matter how long you have held the assets.

For residences, gains are taxable as capital gains…losses are not deductible. If the property is your primary residence rather than a vacation home or other nonprimary residence, the first $250,000 of gains for a single taxpayer and $500,000 for taxpayers filing jointly is not taxed if certain residency requirements are met.

For commercial and rental property, gains are taxed in layers. Gains on sales of the real property are taxed as capital gains, but the portion of the gains to the extent of depreciation that has been previously deducted are taxed at a 25% rate. If tangible property is sold, gains are treated as ordinary income to the extent of previous depreciation. Any excess is taxed as capital gains. Losses might be deductible in full on the real property under IRC §1231, which needs to be reviewed with a tax specialist. The tax is different if the property sold was acquired before 1987.

Realized as well as unrealized net gains from Section 1256 contracts are taxed as 60% long term and 40% short term regardless of the holding period. These are reported on IRS Form 6781. This must be reviewed with a tax specialist. Losses are treated as other capital losses.

Traders that made the mark-to-market election under Section 475 will have their capital gains or losses treated as ordinary gains or losses not subject to the capital gains rates or the annual $3,000 limitation on losses. Investment expenses also will be deductible and treated as from a trade or business. However, such income is not considered as earned income and is not subject to the self-employment tax or eligible for retirement plans unless the trader can be considered as a nonworking spouse, in which case an IRA can be done.

Carried forward losses for a married taxpayer who died during the year cannot be carried forward beyond the year of death. The spouse that did not incur the losses will lose that benefit. If a loss was incurred in the year of death, that can be deducted on the decedent’s final return, including a joint return.

A taxpayer with carried forward losses who was married during a year cannot have those losses offset against a spouse’s gains that were incurred during that year before they were married. Losses incurred after the marriage are deductible on a joint return regardless of which spouse incurred the gains.

Recipients of stock or other capital assets received as a gift use as their basis the basis that applied for the donor if the stock or property has appreciated when the gift was made. If the value when the gift was made was lower, then that lower value becomes the basis. If the donor had a negative basis when the gift was made, the donor would have to recognize that amount as a capital gain at that time.

Stock and other capital assets that are inherited use the value at the date of death (or under certain circumstances the value six months later), thereby avoiding all capital gains taxes through the date used for the inheritance value. This is referred to as the step-up-at-death rule.

Collectibles sold at a gain are taxed at a flat rate of 28%. If the collectible was held for investment purposes and there is a loss, the loss is treated as a capital loss subject to the limitations mentioned above. Collectibles include stamps, coins, precious metals, wine, autographs, art and similar assets. Losses on collectibles not held for investment purposes cannot be deducted.

Collectibles and other capital assets that have appreciated in value can be deductible as a charitable contribution if they are donated to a charity and meet the charity use, reporting and appraisal requirements, and the capital gain will not have to be recognized under that situation.

Gains on sales of small business stock that qualified under IRC §1202 when issued are partially not taxable, with the balance taxable the same as regular stock transactions as are losses.

Losses on sales or dispositions of small-business stock that qualified under IRC §1244 when issued might have a portion be fully deductible with the balance treated as capital losses. Gains are taxable the same as regular stock transactions.

Real estate capital gains can be deferred under IRC §1031 if the sale proceeds are used to acquire like kind property. Tax will only be due upon the disposition of the acquired property. The tax rules must be adhered to.

Capital gains that are reinvested into a Qualified Opportunity Zone can be temporarily deferred, partially reduced or be permanently tax free if the applicable tax law requirements are met.

Gains, including ordinary income, on insurance and annuity contracts can be deferred if the policies are rolled into a qualifying policy under IRC §1035.

Capital gains on the sale of at least 30% of a business to an Employee Stock Ownership Plan (ESOP) can be deferred if the proceeds are invested in US qualifying securities.

Capital gains on the sale of assets by an S corporation will pass through to the owners and will be fully taxed unless they apply their basis by liquidating the S corporation in the year of sale. This is a very important tax maneuver and needs careful planning and execution.

US citizens that have renounced their citizenship and foreigners who were long-term residents that terminate their US residency status for US taxation purposes will be taxed on unrealized capital gains using the mark-to-market rule.

This listing covers the general rules and while it is pretty thorough, it is by no means complete. It is recommended that you check with a knowledgeable tax professional before acting on anything appearing above or for a transaction that might have tax consequences. Not following the exact requirements could make it impossible to receive the intended benefits.

As with any transaction, taxes could be involved and very few transactions have clear and simple tax ramifications.