Electrohydrodynamic fluids possess extensive applications, spanning from the formation of magnetic fields in planets and stars to oil recovery. In this paper, a variational principle for an electrohydrodynamic fluid is presented, and formulated through the semi-inverse method. The Ritz method is utilized to derive an approximate solution. Furthermore, the potential application of this principle to optimal control problems constrained by an electrohydrodynamic fluid is explored.