The influence of interaction of Cs atoms with a dielectric surface on position and shape of the hyperfine components of the D(2)line in the case of nanometer-scale distance between the atom and the surface is investigated. Using a wedged nanocell enabled investigating the dependence of shift of all hyperfine components of the D(2)line corresponding toF(g)= 3 -> F-e= 2, 3, 4 andF(g)= 4 -> F-e= 3, 4, 5 transitions on distanceLbetween the atoms and the surface of a sapphire window in the interval from 50 to 400 nm. AtLsmaller than 100 nm, atomic transitions experience strong broadening due to van der Waals interaction and shift to lower frequencies (the red shift). Calculation of the second derivative (SD) of the absorption spectra of vapors in a nanocell allows spectrally resolving the hyperfine components of an atomic transition down toL similar to 50 nm and determining the van der Waals interaction coefficientC(3). It is demonstrated that the spectrum experiences an additional red shift with increase in the density of atoms atL< 100 nm. In contrast, a blue shift occurs with increase in the density of atoms at relatively large distances between the atoms and the surface (L similar to 400 nm). The above results are important for development of miniature submicron-size devices containing alkali metals.