It depends on why you took the courses and who paid for them.
If you took the online classes as part of your university studies, then tuition, fees and other expenses paid for your online classes may be included as part of the American Opportunity Credit or Lifetime Learning Credit if you are taking your online classes from a college, university, vocational school, or other post-secondary school. This includes books, supplies, and other related equipment you need for your classes.
If you took online courses in order to learn a new trade, to learn abut a hobby, or for personal enrichment then they are not tax deductible.
Online course are as eligible as in person courses. But the same rules must be met. One rule is that
to be eligible for the tuition credits or tuition & fees deduction, the course must be taken at "an eligible institution". The school should be able to tell you if it is an eligible educational institution. In general, an eligible educational institution is an accredited college, university, vocational school, or other postsecondary educational institution, including accredited, public, nonprofit, and proprietary (privately-owned, profit-making) postsecondary institutions. Additionally, in order to be an eligible educational institution, the school must be eligible to participate in a student aid program administered by the Department of Education. If they issue a 1098-T they are probably an eligible institution.
Enter your school at the link below, to see if it's on the dept. of education list.