While butter is often preferred for its rich flavor, margarine can be used as a substitute in cookie recipes. However, there are a few things to consider. Margarine contains more water and less fat than butter, which can affect the texture of the cookies. Cookies made with margarine may spread more and be slightly less flavorful.