Have you ever baked a batch of cookies and had them spread out across the pan, instead of holding their shape? This can especially be a problem if you haven't left much room between the cookies, and they end up bumping into each other.
There are a number of reasons cookies can spread like that, but they're all under your control. You just need to diagnose the reason. (Also, if you happen to want your cookies to spread, you can use the info below in reverse.)
By the way, the assumption is that you've followed the recipe exactly, and didn't, for example, substitute heavy cream for butter. (Believe me, I get some very interesting emails.)
It's also important to measure properly. The most helpful recipes will list ingredients by weight, since volume measurements like cups are notoriously inaccurate. A digital scale you can set to grams is a must-have tool for the home baker.
Oven Temperature is the #1 Culprit
Having said all that, the main reason cookies spread is that the oven isn't hot enough. It's the heat that sets the cookies, and putting cookies into a too-cool oven means the butter will melt before the cookies have a chance to set.
Just because you set your oven to 350°F doesn't mean it's actually 350°. Oven thermostats can go out of whack, so yours might be hotter or cooler than it says. To check, get yourself an oven thermometer (a good one can be had for less than five bucks), and adjust if necessary.
Also, some ovens need longer to preheat than others. You might need to preheat for up to 20 minutes to ensure you hit 350° by the time the cookies actually go in.
By the way, butter isn't the only thing that melts when you bake it. Sugar does, too. So cookies with a lot of sugar in them will tend to spread more than ones with less sugar.
And if you use coarse sugar, your cookies will spread more. Using granulated sugar, superfine sugar or confectioners sugar will reduce spread.
Watch the Water Content of Butter
Another problem is that most butter contains around 19 percent water, and water will cause your cookies to spread. You could substitute shortening, which is 100 percent fat, but then you'd be sacrificing the flavor of butter, which in my opinion is not a worthwhile sacrifice.
European butters and some domestic butters from smaller dairies have less water in them, and they'll cost a bit more. But whatever you do, don't use those tubs of whipped butter. Not only do they have high water content, they also have a lot of air in them, which will also cause your cookies to spread.
I know it's hard to believe, but cookies baked on a light-colored shiny pan will spread more than ones baked on a dark pan. This comes down to temperature again.
Since dark pans absorb more heat, the cookies will set faster. But keep an eye on the cookies to make sure they don't burn on the bottom.
Don't Grease the Pan
If you've controlled all of these factors, you can also chill, or better yet, freeze the dough before you bake it.
Doing this will help the cookies hold their shape longer in the oven. I like to roll the cookie dough into a tube, freeze it, and then cut off slices, arrange them on the baking sheet and bake them.