Taxes can create a huge drain on your investment returns if you're not careful. It's important to keep taxes in mind when you're choosing which types of assets to invest in and what kinds of accounts to stash them in. Matching the right investment with the right account can cut your investment taxes enough to boost your portfolio's profits by a few percentage points.

Here's what you need to know to minimize the taxes you pay on your investments.

Types of investment taxes

Any time you sell an investment at a gain, you're opening yourself up to capital gains taxes. This is a tax on the profits you make from selling an asset, and the tax rate you pay depends on how long you've owned the asset. If you've owned it for more than a year before selling, it's categorized as a "long-term investment" and will be taxed at the relatively low long-term capital gains rate. If you've owned it for one year or less, you'll be charged the short-term capital gains rate instead, which is always equivalent to your highest tax bracket for the year.

Many stocks pay dividends as a way to share the company's profits with its shareholders. Unfortunately, dividends are taxed by the federal government. The IRS breaks dividends out into two classes: qualified and unqualified. Qualified dividends, which include dividends from domestic corporations and qualified foreign corporations, are taxed at the long-term capital gains tax rate. Unqualified dividends -- which include those from REITs, master limited partnerships (MLPs), and tax-exempt companies -- are taxed at your ordinary income tax rate just as short-term capital gains are.

Finally, bonds and many cash-equivalent investments (including bank savings accounts and CDs) pay their investors interest, which is also taxed. Interest that you receive from these and other sources is taxed at your ordinary income tax rate.

Check to the IRS for 'all my money'

Image source: Getty Images.

Investments with special tax treatment

Certain types of investments are treated differently when it comes to taxes and tax rates. Sometimes that's a good thing, as in the case of municipal bonds: If you buy municipal bonds issued by the state in which you live, the bonds' interest will be exempt from both state and federal taxes. Sometimes it's a bad thing, as with the aforementioned REITs and MLPs. REITs in particular can be a problem from a tax standpoint, because they are required by law to pay out all their profits as dividends, often leading to extremely high dividend yields -- and those dividends will be taxed at the higher, unqualified rate. Before buying any investment, it's important to find out how the investment will be taxed, as this can make a considerable difference in how profitable that investment will truly be.

Accounts with special tax treatment

Fortunately, you don't have to give up on investments like REITs just because of their high taxes. Certain types of investment accounts extend favorable tax treatment to all the investments held inside of them, regardless of how those investments would normally be taxed. These special tax-advantaged accounts include IRAs, 401(k)s, and HSAs.

Investments inside a tax-advantaged account are completely immune to capital gains taxes. Moreover, interest and dividends are not taxed when they're received. Some types of tax-advantaged accounts require you to pay income taxes on the money you withdraw from the account, but HSAs and Roth IRAs offer tax-free withdrawals, so interest and dividends are completely tax-free within these accounts.

Thus tax-advantaged accounts allow you to have your cake and eat it, too: You can buy investments like REITs within your IRA and enjoy the high dividend yields without suffering a high tax bill as a result. Meanwhile, tax-advantaged investments such as municipal bonds can live in your standard brokerage account. Match up the right investments with the right accounts, and you may not have to pay a dime in investment taxes.