The Carex flava aggregate belongs to one of the most taxonomically difficult groups of sedges which colonize diverse habitats, from organic to sandy, from acidic to alkaline, usually humid and moist. The study included 129 vegetation plots and ten soil variables (organic matter, phosphorus, potassium, magnesium, calcium, carbonates, carbon, nitrogen, pH, and the ratio between organic carbon and nitrogen). The main aim was to determine the relationships between the various plant communities C. flava agg. occur in and their soil properties. With the aid of the two-way indicator species analysis and cluster analysis, we delimited nine vegetation types from the Scheuchzerio palustris-Caricetea fuscae, Littorelletea uniflorae, Molinio-Arrhenatheretea and Alnetea glutinosae classes differing in their response to soil properties. The CCA revealed pH, N, K, C, CaCO3, P and Ca to be statistically significant, and to account for 11.55% of the total variance in species composition. The largest differences, both in terms of species composition and in soil conditions, were revealed between communities with C. lepidocarpa and C. demissa. Carex lepidocarpa occurred in calcareous and extremely rich fens (Caricion davallianae) whereas C. demissa was found to occur in poor and moderately rich fens (Sphagno-Caricion canescentis, Caricion canescenti-nigrae). Carex flava grew mostly in calcareous, rich fens and wet grasslands (Caricion davallianae, Calthion palustris). Carex viridula was found in both calcareous, extremely and moderately rich fens and wet grasslands, and in nutrient-poor habitats such as dunes and sandy lake shores. The ecological niche of C. viridula is very wide and this species showed no affinity to any specific syntaxon.