In this paper, we study the existence, regularity, and approximation of the solution for a class of nonlinear fractional differential equations. For this aim, suitable variational formulations are defined for a nonlinear boundary value problems with Riemann-Liouville and Caputo fractional derivatives together with the homogeneous Dirichlet condition. We concern the well-posedness and also the regularity of the corresponding weak solutions. Then, we develop a Galerkin finite element approach to proceed the numerical approximation of the weak formulations and prove a priori error estimations. Finally, some numerical experiments are provided to explain the accuracy of the proposed method.