Investments can be unpredictable. But the tax rules for certain investments can get confusing, which can add to the surprise.

Here are four types of investments that could leave you with an unexpected bill at tax time. Note that the potential tax bill doesn't mean you should avoid these investments. Just be aware of the rules so you aren't caught off guard.

A pile of gold bars and bricks.

Image source: Getty Images.

Gold and silver

The prices of gold and silver finished out 2020 up 24% and 39%, respectively, from the beginning of the year. If you profited off either precious metal in physical form, be prepared for the tax bill. While long-term capital gains tax rates cap out at 20% for most investments, the IRS taxes gold and silver as a collectible. You'll be taxed at the same rate you would be if you sold a piece of artwork or your stamp collection -- and the maximum long-term tax rate is 28%, rather than 20%.

The rules for gold and silver exchange-traded funds (ETFs) are complex, but if you sold shares of an ETF that owns the physical metal after holding them longer than a year, you could be taxed at the 28% rate if your ordinary income is taxed at a rate of 28% or higher. It's essential to use the information on the tax forms that the ETF issuer provides and work with a tax professional to make sure you get things right. If you invested in gold or silver mining stocks, no need to worry. The usual tax rules for selling stocks will apply.

Two workers stand underneath a highway project.

Image source: Getty Images.

Municipal bonds

Many retirees love municipal bonds because the federal government doesn't tax the interest income. But here's where it gets tricky if you're on Social Security: Muni bond income is considered in calculating your modified adjusted gross income, or MAGI, which determines how much of your Social Security is taxed. 

Up to 50% of benefits are taxable for singles with income between $25,000 and $34,000 per year or married couples filing jointly with an income between $32,000 and $44,000. For those with incomes above $34,000 for individuals and $44,000 for couples, up to 85% of Social Security benefits are taxable. 

Money pouring out of a faucet representing a dividend income stream.

Image source: Getty Images.

Dividend stocks

If you invest in dividend stocks, your tax bill depends on a number of factors, including your marginal tax rate, whether it's a qualified dividend or nonqualified dividend, and what type of investment account you're holding the stock in.

One thing that surprises some investors: That money is usually taxable, even if you automatically reinvest dividends using your brokerage account or the company's dividend reinvestment program (DRIP). Qualified dividends are taxed at rates of 0%, 15%, or 20% -- the same rates as regular long-term capital gains -- whereas nonqualified dividends are taxed at ordinary income rates.

A screen displays real-time stock market quotes.

Image source: Getty Images.

Any stock you hold for less than a year

A buy-and-hold strategy is the best way to build wealth because it allows you to take advantage of long-term growth, rather than betting on short-term fluctuations. In case you need another reason to avoid frequent trading, consider the tax consequences.

When you sell a stock you've held for more than one year , you get those favorable long-term capital gains tax rates of 0%, 15%, or 20%. But any profit you earn in a taxable account from selling a stock you've held for less than a year is taxed at your ordinary income rates. You can offset your capital gains with losses, but overall, you'll get the most favorable tax treatment when you invest for the long term.

What if you can't afford the tax bill?

If you're ever unable to pay your taxes for any reason, it's essential that you file a tax return anyway. The penalties for failure to file are much steeper than the penalties for not paying on time. The IRS has a number of payment plans that you can set up online. Typically, you won't need to provide additional information as long as your tax bill is $25,000 or less.