Both should work, certainly. I would even argue that browsers should accomodate this not, and search both. But they don’t (always).
So when you are setting up DNS for a domain, set up both domain_name.com AND www.domain_name.com. It really shouldn’t cost you a nickel more, and shouldn’t take more than an extra few seconds.
But it can save you a ton of missed visits.