The polarized absorption spectra for Ho3+ and Er3+ in LiHoF4 and LiErF4, respectively, have been recorded in the spectral interval 4000-26 000 cm-1 at 2 K. Parts of the spectra were examined at higher temperatures. The experimental levels for Ho3+ and Er3+ in LiRF4 were close to those found in LiYF4. The energy levels of the ground-state term for each ion were calculated by diagonalizing in a term basis an effective Hamiltonian, which takes into account the mixing with other terms due to the spin-orbit coupling. The calculations could not give the correct centers of gravity for the multiplets. After the centers of gravity were matched with the experimental centers, the crystal-field parameters were varied to obtain the best agreement with the experimental observations. For Ho3+ the agreement obtained was good, but for Er3+ it was not possible to get good agreement for the levels of all the multiplets of the ground-state term. With the crystal-field parameters obtained for Er3+ when fitting to the levels of the two lowest multiplets only, all the energy levels below 26 000 cm-1 were calculated by diagonalizing the energy Hamiltonian in a configuration basis. This calculation showed that the term mixing was strong even for the multiplets of the ground-state term. The agreement with the experiments was good for the three lowest terms of Er3+. The fitted values for the crystal-field parameters in LiRF4 were for Ho3+ close to the values reported in LiYF4, whereas the parameters differed somewhat in the case of Er3+.