We present a current–density functional theory (CDFT) for a superconductor applied by an external magnetic field. As the formulation is free from the assumption of the v-representability of densities, the fictitious external pairing field is not needed. The anomalous density, which corresponds to the order parameter of a superconducting phase, is treated in a nonlocal form as it should be. To perform actual calculations, the exchange–correlation (xc) energy functional is a key quantity as is the case with the conventional CDFT of a normal state. As the first step toward developing the approximate form, we present the exact expression for the xc energy functional with the aid of the coupling-constant integration technique. This scheme may become a first-principles theory which can evaluate not only the critical temperature but also critical magnetic field quantitatively. © 2012 Wiley Periodicals, Inc.