Density is a way of measuring how much of something we have in a determined space or volume, and it is also widely used in Chemistry, the way to calculate density is by dividing the mass of the substance by the volume:
ρ = m/v
As you can see, density depends on the mass, since mass is one part of the formula