Can margarine be a substitute for oil?

Margarine can sometimes be used as a substitute for oil in baking, but the end result may be different. Margarine is a solid at room temperature, while oil is a liquid. This means that margarine can make baked goods more dense and crumbly than oil. Additionally, margarine contains water, which can make baked goods more moist. When using margarine instead of oil, it is important to use the same amount by weight, and not by volume.