With college costs climbing at a staggering rate, many students have no choice but to rack up debt to fund their studies. In fact, the average Class of 2017 graduate came away $39,400 in the hole.

For some graduates, those loans are a small price to pay for the promise of a higher salary. Workers with college diplomas, on average, earn roughly 56% more than those with only high school diplomas. And as of 2015, workers aged 25 to 34 with college degrees earned about $20,000 more than similarly aged workers without degrees.

Graduation cap on a pile of hundred dollar bills.

Image source: Getty Images.

Still, for many grads, the burden of student debt isn't worth the upside. In fact, 46% of borrowers regret having taken out loans for college, according to data from EDVestinU. And 52% say they've struggled to pay back their loans after their respective grace periods have lapsed.

If you're planning to attend college, it pays to keep your costs to a minimum, because doing so will, in turn, keep your loans to a minimum. But it also pays to borrow smartly to avoid regretting that decision down the line.

The right way to borrow for college

The big question in taking out student loans pretty much boils down to whether you'll manage to pay them back. And a good way to ensure that you don't end up falling behind on your loans -- and wrecking your credit in the process -- is to stick to federal loans.

If you're considered a dependent student from a tax perspective (meaning, your parents claim you as a dependent on their tax return), then the total amount you're allowed to borrow in federal loans (subsidized and unsubsidized) is $31,000. Now you'll get some leeway if you pay down a portion of your loans while in school -- at that point, you'll be eligible to borrow again up to that $31,000 total. But generally speaking, that $31,000 cap is what you're working with, and that's sort of a good thing and a bad thing.

First, the positive: Putting a cap on borrowing helps ensure that students don't get in over their heads. The flipside, however, is that when borrowers exhaust their federal loan options, they frequently resort to private loans instead. And that's where they really run into trouble.

The problem with private loans is that they tend to be far more expensive than federal loans, at least from an interest rate perspective. Whereas federal loans are regulated, private loans aren't subject to the same requirements, which means lenders can get away with charging exorbitant rates to college students who feel they have no choice but to take what they can get. Furthermore, private loans often come with variable interest rates, and if they rise over time, so too can your payments.

Private student loans also don't offer the same borrower protections as federal loans. With the latter, you can apply for deferment and income-based repayment plans to avoid defaulting on your loans -- but such programs don't typically exist with private loans. And because private loans don't impose borrowing limits like federal loans, it's easy enough to rack up a mountain of debt without actually realizing what sort of hole you're digging yourself into.

Therefore, if you're going to borrow money for college and don't want to end up regretting it, tell yourself you won't turn to private loans once your federal options are maxed out. You may need to work during your studies, or even take a year or two off to save, in order to cover your education costs with federal loans alone. The upside? You'll limit the extent to which that debt drags you down after the fact. And the more manageable you keep your payments, the less likely you are to join the ranks of the millions of Americans who are currently bemoaning the decision to borrow in the first place.

The Motley Fool has a disclosure policy.