Fish behaviour can change to accommodate a variable environment, but changes in behaviour have not been considered in the context of density-dependent habitat use. In Bonavista Bay, Newfoundland, we measured how fish density movement and schooling behaviour changed with habitat in 2 gadids, Atlantic cod Gadus morhua and Greenland cod Gadus ogac, using a combination of field-seines, mark-recapture and laboratory experiments. Density estimates from seines (n = 427) over 5 yr (1996, 1998 to 2001) indicated that these species associated with eelgrass but periodically were detected in high abundance over unvegetated habitat (i.e. sand). Within-site catch variation indicated both species aggregated more in sand than eelgrass habitat, and, in Atlantic cod, aggregations over sand increased as density in eelgrass increased. Although such patterns in catch data could be interpreted as due to the effects of differential mortality between habitats, a mark-recapture experiment indicated that both species of cod were not site-attached and moved between seine locations. Furthermore, video-analysis from laboratory experiments demonstrated that cod formed tighter aggregations over sand compared to eelgrass habitats. Our results suggest that juvenile cod modify their behaviour with changing density, possibly as a means of exploiting poor-quality habitats when high-quality habitats are saturated with conspecifics. Consequently, habitat suitability for Atlantic cod may be a dynamic rather than fixed variable in density-dependent habitat models.