We study the design of taxes aimed at limiting externalities in markets characterized by differentiated products and imperfect competition. In such settings policy must balance distortions from externalities with those associated with the exercise of market power; the optimal tax rate depends on the nature of external harms, how the degree of market power among externality generating products compares with non-taxed alternatives, and how consumers switch across these products. We apply the framework to the topical question of taxes on sugar sweetened beverages. We use detailed data on the UK market for drinks to estimate a model of consumer demand and oligopoly pricing for the differentiated products in the market. We show the welfare maximizing tax rate leads to welfare improvements over 2.5 times as large as that associated with policy that ignores distortions associated with the exercise of market power.