Yes, you can generally substitute margarine for butter in most recipes, including baking and cooking. However, because the flavour and water content can vary, the end result might not taste or look the same.