Before we get to the question of whether you can substitute butter for margarine and vice versa, here’s another question for you: Did you know that the production and sale of margarine was once banned in six states? Although they now sit side by side in the dairy aisle, the relationship between butter and margarine has been anything but smooth.

While they may look indistinguishable once slathered on toast, a bit of investigation reveals that the differences between these two savory spreads abound. So what exactly is the difference between butter and margarine?

Starting simple, butter is a dairy product made from milk or cream (which makes homemade butter surprisingly easy), while vegetable oil is the key ingredient in margarine.

Civilizations across the globe have been enjoying butter for millennia. On the other hand, the original margarine formula was invented by a French chemist in 1869 as a butter substitute. A cheaper alternative to butter, it arrived in the U.S. in the 1870s, much to the dismay of the dairy industry. As margarine companies popped up left and right, pro-dairy lobbyists fought the changing tides with efforts to impose restrictions, taxes, and licensing fees on the new margarine producers.

Butter is naturally yellow, since most butter-producing cows munch on grass that’s rich in the pigment beta carotene. On the other hand, undyed margarine is actually white. When early margarine producers started adding yellow dye to the mix in order to position their product as a substitute for butter, the dairy industry sprang into action. At one point, 32 states enacted restrictions on the dyeing of margarine. Three went so far as to demand that margarine must be dyed an unsettling shade of pink. To this day, restrictions around dyed margarine can still be found in Wisconsin law, including this selection from Statute 97.18: “The serving of colored oleomargarine or margarine at a public eating place as a substitute for table butter is prohibited unless it is ordered by the customer.”

Since butter is an animal product, it contains saturated fats and cholesterol. While margarine typically has less saturated fat and cholesterol than butter, it historically contained trans fats. These trans fats were created as a byproduct of the hydrogenation process that transformed the vegetable oil from a liquid to a semi-solid. In response to growing evidence that trans fats posed a serious threat to heart health, margarine producers were faced with reworking their formulas. Beginning in January 2006, the Food and Drug Administration called for the required labeling of trans fats on food packaging. Then in 2015, it went so far as to call for the elimination of trans fats by 2018. These days, most margarine containers boast zero grams of trans fats per serving and what some health specialists refer to as “good fats”—also known as polyunsaturated and monounsaturated fats. But it should be noted that companies are only required to list trans fats on food labels if the product contains more than half a gram per serving.

While both margarine and butter contain roughly the same amount of calories per serving (about 100 calories per 14 grams) it’s worth noting there are different types of margarine. As mentioned some margarine contains trans fat and, as a rule of thumb, the more solid the margarine, the more trans fat are in it. Stick margarine, for the most part, contain more trans fat than tub margarine or light margarine does. Regular butter and whipped butter, the two most common types, contain mostly the same ingredients, nutrition, and fat content.

Thanks to its lower price point and a (now discredited) reputation as a healthier alternative to butter, given it’s lower saturated fats and cholesterol counts and zero use of animal fat, vegetable oil-based margarine spent many years in the sun. But as new information arises and a preference for natural products prevails, butter looks to be reclaiming the top spot with margarine ceding the lead. As one headline from The Economist put it: “Margarine sales: investors can’t believe they’re not better.”

Butter’s image rehab paints a drastic before-and-after picture. Not only is it now outselling margarine, but some are pointing to butter as the next artisanal food trend with organic versions made from grass-fed cows readily available nationwide. Other dairy products like ice cream and cheese are available in a plethora of styles and flavors. Could butter be next?

So which is right for you, butter or margarine? Depending on your diet (margarine is vegan), recommended fat intake and other immediate health goals it may vary, but a cardiologist will probably tell you margarine (with no trans fat and low saturated fat) tops butter for general heart health while 99 percent of chefs will tell you nothing beats real butter.

Simply put: yes! Whether cooking or baking, butter and margarine can be swapped one for another at a 1:1 ratio—but you will often notice both textural and flavor differences. For some, they’re minor enough not to matter, and others actually prefer the effect margarine has on a cake or cookie recipe. So go ahead and try it.