Two compounds, tetragonal YB4 and cubic YB6, have been investigated by electric-field gradient (EFG) and Knight shift measurements at the boron sites using the 11B nuclear magnetic resonance (NMR) technique and by performing first-principles calculations. In YB611B (I=3/2) NMR spectra reveal patterns typical for an axially symmetric field gradient with a quadrupole coupling frequency of νQ=600±15kHz. In the second boride (YB4) three different EFGs were observed corresponding to the three inequivalent crystallographic sites for the boron atoms (4h, 4e, and 8j). They correspond to: νQ(4h)=700±30kHz with an asymmetry parameter η=0.02±0.02, νQ(4e)=515±30kHz, η=0.00+0.02/−0.00, and νQ(8j)=515±40kHz, η=0.46±0.08. The Knight shifts measured by magic-angle spinning (MAS) NMR at room temperature are very small being 0.6±8 and −1±8ppm for YB4 and YB6, respectively. For the theoretical calculations structure optimizations were performed as a first step. For the obtained structural parameters the EFGs were computed within the local-density approximation. Very satisfactory agreement between experimental and theoretical results is obtained both for the structural parameters and the B EFGs, thus confirming the underlying structural models. In addition to the EFGs, band structures, densities of states, and valence-electron densities are presented and the bonding situation in the two yttrium borides is discussed. The band-structure results are compatible with the very low values for the Knight shifts mentioned above.