Yes, you can! There's no rule that says you can't do both. In fact, many authors opt to traditional publish their work initially, then self-publish later down the line.
There are benefits to both routes. Traditional publishing offers advances and the support of a publishing house, while self-publishing gives you full creative control and a larger share of the profits.
It's ultimately up to you which route you want to go down. If you're not sure, why not try submitting your work to agents and see what happens? If you're not having any luck, then self-publishing might be the way to go.
Of course, you can always do a combination of both. Some authors will traditional publish some of their work and self-publish the rest. It's all about what works best for you and your career.