www.foo.com is not strictly speaking a URL. It's a relative domain name.
It means this: start with your local domains, falling back to the root if you can't find anything there and traverse through
foo to get to
www. It doesn't say what records to grab from that domain though or what you would do with those records if you did retrieve them.
Most commonly the record of interest is an address record which allows the domain name to be used as a hostname to refer to a machine. There are other kinds of DNS records though.
www is just the last name in the chain, and it is completely arbitrary. There's a convention of naming the host of the primary Web server for a domain
www but that is just a convenience for humans, not something meant to be recognizable to machines. Even then, there are things you can do with machines running webservers other than requesting Web pages from them.
So, not all web servers are named
www and just naming one doesn't say what you want to do with it anyway.
That's where URL come in. They tell you how to get to something. They start by telling you how to get it, then where.
How is specified as a "sheme" and for the web, the scheme is either
http for regular requests or
https for secure requests. Then a separator
:// then a hostname telling you where the web server is (maybe a DNS name, maybe something else like an I address or a locally defined name) then a path indicating where the pages is on the web server. (There are a bunch of details I'm skipping over).
It is generally considered good practice to allow
www but not encourage it by pointing the address records of both the base domain and that plus
www at we servers meant to act as public facing entry points, and then to favour the non
If you want to provide a proper URL that unambiguously shows that you are referring to a website, provide a full URL.