The continuum theory of micromagnetism is used to study ultrathin films with magnetic anisotropy varying laterally on the nanometer scale. A series of infinitely long stripes with alternating in- and out-of-plane uniaxial anisotropy is considered as a model for patterned ferromagnetic films. The analytical solution based on an effective anisotropy description of the dipolar energy is given as a function of the material parameters (exchange and anisotropy constants) and the width of the stripes. States of uniform and non-uniform magnetization are obtained. For film of finite thickness the exact value of the dipolar energy is calculated numerically and the numerical solution is compared with the analytical one. We find that the correction to the dipolar energy is negligible for nickel, while for cobalt and iron it has to be considered as a function of the anisotropies, the width of the stripes and the thickness of the film. (C) 2003 Elsevier B.V. All rights reserved.