Let $L$ be a finite dimensional Lie algebra over a field of characteristic $0$. Then by the original Levi theorem, $L = B \oplus R$ where $R$ is the solvable radical and $B$ is some maximal semisimple subalgebra. We prove that if $L$ is an $H$-(co)module algebra for a finite dimensional (co)semisimple Hopf algebra $H$, then $R$ is $H$-(co)invariant and $B$ can be chosen to be $H$-(co)invariant too. Moreover, the nilpotent radical $N$ of $L$ is $H$-(co)invariant and there exists an $H$-sub(co)module $S\subseteq R$ such that $R=S\oplus N$ and $[B,S]=0$. In addition, the $H$-(co)invariant analog of the Weyl theorem is proved. In fact, under certain conditions, these results hold for an $H$-comodule Lie algebra $L$, even if $H$ is infinite dimensional. In particular, if $L$ is a Lie algebra graded by an arbitrary group $G$, then $B$ can be chosen to be graded, and if $L$ is a Lie algebra with a rational action of a reductive affine algebraic group $G$ by automorphisms, then $B$ can be chosen to be $G$-invariant. Also we prove that every finite dimensional semisimple $H$-(co)module Lie algebra over a field of characteristic $0$ is a direct sum of its minimal $H$-(co)invariant ideals.