We quantify the importance of collateral versus taxes for firms' capital structures. We estimate a dynamic model in which a taxable firm seeks financing for investment, and a dynamic contracting environment motivates endogenous collateral constraints. Optimal leverage stays a safe distance from the constraint, balancing the tax benefit of debt with the cost of lost financial flexibility. We estimate this flexibility cost to be 7.2% of firm assets, a percentage that is comparable to the tax benefit. Models with different tax rates fit the data equally well, and leverage responds to the tax rate only when taxes are low.