The size dependence of the coupling between longitudinal optical phonons and electron-hole pairs in InxGa1-xN/GaN quantum wells and quantum boxes has been investigated. The distribution of luminescence intensities between the phonon replicas and the zero-phonon peak is found to depend significantly on the well width or the vertical size of the boxes. The Huang-Rhys factor, S, which describes the strength of the coupling between LO-phonons and electron-hole pairs, increases steadily with the vertical size. This behavior is assigned to 1. the spontaneous and piezoelectric polarization-induced strong electric field along the growth axis of the system and 2. to the localization of electrons and holes at opposite sides of the well (or box) resulting from potential fluctuations in the ternary alloy. This conclusion is reinforced by envelope function calculations of S, for free or localized excitons, where only the Coulomb interaction is responsible for the electron-hole distance. This model does not give any quantitative agreement with the experimental results which are rather similar to what is obtained for donor-acceptor pairs, with separate centers of localization for electrons and for holes.