When you sell your investments for a profit, you generally have to pay capital gains tax. But what is capital gains tax, and how does it differ from regular income tax? Many investors don't know how much they'll have to pay when they sell investments, how the time frame of the investment comes into play, or how they can get out of paying the tax altogether. Here is a quick guide on what you, as an investor, need to know about capital gains tax.

What is capital gains tax?
Capital gains tax is what you need to pay to the IRS if you profited from the sale of your assets or investments, and it doesn't just apply to stocks. If you bought a car for $2,000 and sold it for $2,500, you might be on the hook for taxes on the $500 profit. Technically, any property you sell for more than you paid for it qualifies as a capital gain.

One of the most unfair things about capital gains tax is that you have to pay it on any profits from the sale of property, but you can only deduct losses on property that was purchased as an investment. So when you buy a couch for $1,000 and sell it for $300 years later, you can't write off the difference, but if you sell it for more than $1,000, you'll get taxed on the profit.

The good news is that the tax rates you pay on capital gains is generally lower than what you pay on ordinary income, and the rates depend on how long you held the property.

Time is the most important factor
If you owned the investment (or property) for less than one year, your profits are taxed as ordinary income. If you held on for more than a year, you'll pay the lower capital gains rates.

As of 2014, the long-term capital gains tax rate for the 10% and 15% tax brackets is 0%. In other words, if your ordinary taxable income is less than $36,900 ($73,800 for married couples filing jointly), you'll pay absolutely no tax if you sell long-term stock holdings for a profit.

For most other income tax brackets, which represent $36,901 to $406,750 in taxable income ($73,800 to $457,600 if married), the capital gains tax is 15%. So, yes, you'll get hit by the tax man, but it's still much less than you pay on your ordinary income.

For the 39.6% tax bracket, which represents the highest-paid Americans, the capital gains tax is 20%, or about half of the normal tax rate.

The best way to get out of paying capital gains tax for your investments
When it comes to stocks, bonds, and other investments you can hold in a brokerage account, the most certain way to get out of paying capital gains tax is to hold your investments in a tax-deferred or tax-free account such as a Roth IRA.

With a Roth IRA, your contributions are not tax-deductible, but any withdrawals made after you reach 59-1/2 years of age are tax-free, regardless of how much profit you made.

Before you contribute any of your long-term savings to a traditional brokerage account, make sure you max out the tax-free options available to you. As of 2014, the most you can contribute to an IRA is $5,500, or $6,500 if you're over 50.

Use the 0% capital gains rate if you can
Sure, the income numbers for the 10% and 15% tax brackets may seem a bit low, and they are. However, there are some important points to keep in mind.

First, the income numbers in tax brackets refer to taxable income, or your gross income minus any adjustments and deductions. So, if you're a married couple who earns $80,000, but you have $20,000 in deductions, exemptions, etc., you'd still be in the 15% tax bracket and could have up to $13,800 in capital gains that would be tax-free.

Second, when you will need your investments the most, in retirement, you'll most likely have very low gross income to report. So even if you earned $150,000 per year during your career, if your wages drop to zero because of retirement, that qualifies you for the 0% capital gains bracket on any investment profits up to the threshold incomes I've mentioned here.