Moduli spaces of algebraic curves are closely related to Hurwitz spaces, that is, spaces of meromorphic functions on curves. All of these spaces naturally arise in numerous problems of algebraic geometry and mathematical physics, especially in connection with string theory and Gromov-Witten invariants. In particular, the classical Hurwitz problem of enumerating the topologically distinct ramified coverings of the sphere with prescribed ramification type reduces to the study of the geometry and topology of these spaces. The cohomology rings of such spaces are complicated even in the simple case of rational curves and functions. However, the cohomology classes most important for applications (namely, the classes Poincaré dual to the strata of functions with given singularities) can be expressed in terms of relatively simple "basic" classes (which are, in a sense, tautological). The aim of the present paper is to identify these basic classes, to describe relations between them, and to find expressions for the strata in terms of them. Our approach is based on Thorn's theory of universal polynomials of singularities, which has been extended to the case of multisingularities by the first author. Although the general Hurwitz problem still remains open, our approach enables one to achieve significant progress towards its solution and an understanding of the geometry and topology of Hurwitz spaces.