The true dynamical degrees of freedom (TDDF) of the electromagnetic potential are found for any gauge. They are the components of the Fourier transform of the electromagnetic potential on a two-dimensional spacelike plane orthogonal to the lightlike momentum vector for k2 = 0 and vanish for k2 ≠ 0. Gauge invariance is related to the (two-parameter) indeterminacy of this spacelike plane and the arbitrariness of the component of the electromagnetic potential along the momentum vector. By direct quantization of the TDDF for any gauge (compatible with the equations of motion), some of the well-known problems of the usual treatments are avoided. For instance, the constraint div E = 0 is a c-number (agrees with the commutation relations) without choosing a gauge, there appears no need for an indefinite metric in the space of state amplitudes, the commutators for creation and annihilation operators of every component of the electromagnetic potential (timelike, longitudinal, and transverse) have the same sign, and the energy of the electromagnetic field is positive for any gauge. When gauges are chosen, the results of the literature are recovered. In our treatment, gauge fixation and quantization commute.