Can you attend law school online?

Sort of. There are online law schools, but they are unaccredited. Most states will not let you sit for the bar exam unless you are a graduate of an accredited law school. California is the only one that does, but you have to take supplemental exams in the middle of law school to be admitted to take the final one. Even then, you will not be competitive for jobs there.

So you can go to an online law school if you just want to learn about the law, but it is a very bad idea if you hope to be a lawyer.