Yes, you can. I know a few people that have done this and are very good. However, for classical piano at least, you will usually be limited with what you can do.
Learning the piano is like anything else. If you tried to learn to drive without an instructor, then you are going to struggle. It will take longer, and you will pick up bad habits along the way that will probably stay with you all your life.
If you are only looking to pick up a few songs and play just a little for fun, then there’s nothing wrong with buying some books and teaching yourself. Online videos are also really helpful. However, be prepared to limit yourself with what you can do, and understand that you will only get so far.
When you teach yourself classical piano, you miss out on the much needed interaction. If you are doing something wrong, then you might never know unless someone is there to point it out to you. Books and online videos also won’t be able to show you a different way of doing things, in case it’s not working for you. There are also times when you need to be pushed and given encouragement, which is one of the most important parts when learning something new.
If you can’t yet read music and you are an absolute beginner, then my advice would be to buy books and teach yourself for a while. Maybe 3-6 months as a minimum. Once you can read music to a fairly good standard, and you are able to play a little on the piano, then it might be a good time to seek out classical piano lessons. I can guarantee you that after the first month of piano lessons, you will notice a huge difference in your ability and knowledge, than what you could ever pick up by yourself.
Learning blues piano is a little different. By nature, blues piano is quite modular – left hands, right hands, bridges, intros, endings and so on. It therefore makes perfect sense to learn blues piano from a modular course that gradually builds on your ability. I’d recommend a course that includes technique, such as improvisation – as this is what you’ll need to learn to be a really great blues piano player.