Finite element methods are known to produce spurious oscillations when the transport equation is solved. In this paper, a variational formulation for the transport equation is proposed, and by introducing a positivity constraint combined with a penalization of the total variation of the solution, a discrete maximum principle is verified for lagrange first order finite element methods. Moreover, the oscillations are cancelled