Note: This article is written with the assumption you know very little about the technical, inner-workings of DNS. If you are looking for a more technical answer, I like this answer (and its comments) a lot.
Remember those days when everyone would say, "My website is double-yoo-double-yoo-double-yoo-dot-blah-blah-blah"? And, do you notice how it still happens today? Why are websites presented in this way?
Or, to think of this question a different way, consider an example. If you go to www.twitter.com, you are redirected to twitter.com. And, in contrast, if you go to facebook.com, you are redirected to www.facebook.com.
What the heck?
What "www" Means
First, what are we really talking about?
You may have heard the term domain before. We refer to facebook.com and twitter.com as domains. I've discussed this when I wrote a basic article on how the web works. The TL;DR version of that post is essentially this:
When you type in a URL in your browser, the browser (if it doesn't have the domain name stored in memory) will contact a domain name server to ask which IP address the domain names points to. It then sends you to the correct IP address and renders the html (or other data) sent to it.
An IP address is essentially a unique way to identify a machine accessing the internet.
The administrator of a domain (which might be you if you own the domain!) gets to choose the IP address to which their domain points. This is done via a DNS zone file.
You've probably been to sites that are considered subdomains of the root domain. For example, About has a main website at www.about.com (notice the www). But they also have several other websites. One such example is bbq.about.com.
In this case, the administrator of the about.com domain can choose which IP address to point www and bbq to (and they don't have to be the same).
Note: This significantly simplifies what the administrator of the large about.com domain actually has to do, but we're using it as an example.
Using this logic, the main Facebook application is actually using a subdomain, and that subdomain uses the www prefix. Meanwhile, Twitter's main application uses their naked domain, or a domain with no subdomain/prefix.
A Utilitarian "www"
So, we've established what www is, but why is it used?
Well, I've been using websites for my examples, but there are many other uses for a domain. Domains can also be used for a mail server (how you receive emails), which is typically at a mail subdomain (for example, mail.google.com), or even ftp for file transfer and file sharing. The examples for domain usage go on and on.
So, www became (by some means I didn't research) the standard prefix to use for one's public website.
What's better – www or no www?
To answer this question, consider:
- your technical configuration
- how to market your website
- accounting for both cases
Your Technical Configuration
There are some sites out there that recommend you do not use a naked domain, but always use some subdomain for your main website. This typically happens when either a) you have a really, really large site that needs to consider load balancing, or b) you are outsourcing hosting to a service that suggests or requires it.
Furthermore, depending on the age of your domain, you may be pigeonholed into not being able to use the naked domain for your public website.
I think both of these scenarios are understandable and fine. There are many out there against me, but for the simplicity of it, I prefer no www unless your configuration requires it.
How to Market Your Website
You got a really awesome, four-syllable domain name, right? Something like "Goo-gle-dot-com" or "a-bout-dot-com" or "twit-ter-dot-com"?
Great! So, why the heck would you say, "My website is www.google.com!" even if it is? Doing so adds 10 syllables to your domain name.
I know, I know. This sounds stupid and arbitrary. But really, you saying "www" is the part that is stupid and arbitrary.
So, if you're going to use www (which we've established is completely fine), don't write it on business cards and for Pete's sake, don't say it out loud. Just make sure you …
Account for Both Cases
Whether or not you use or don't use www, one thing will always be true – you need to account for both cases. No matter how you configure or promote your domain, people are going to go to yourdomain.com and www.yourdomain.com, simply because different people use the web differently.
But, for purposes of SEO (search engine optimization), you should keep your main domain, and redirect the other to that domain. This is better for search engines and for accurate analytics.
Note: If you're using Nginx as your web server, I wrote a quick post on how to redirect www.