Colocated multiple-input multiple-output (MIMO) radar can transmit a group of distinct waveforms via its colocated transmit antennas and the waveform diversity leads to several advantages in contrast to conventional phased-array radar. The performance depends highly on the degrees available, and element spacing can be deemed as another source of degrees of freedom. In this paper, we study the joint waveform and element spacing optimization problem. A joint waveform and array optimization criterion is proposed to match the transmit beampattern, the suppression range, and the angular sidelobes, under the constraints of minimal element spacing and total array aperture. Meanwhile, the effect of receive beamforming on suppressing mutual correlation between returns from different spatial directions is also incorporated into the optimization criterion. The optimization problem is solved by the sequential quadratic programming algorithm. Numerical results indicate that with more degrees of freedom from array spacings, colocated MIMO radar achieves a better transmit beampattern matching performance and a lower sidelobe level, compared with a fixed half-wavelength spaced array, but the benefits from additional degrees of freedom from array spacing optimization have a limit.