Everyone has their own way of learning and retaining knowledge.
There are so many methods when it comes to learning: reading books, video tutorials, coding along, and many others. I've found myself going back and forth depending on where I'm at or if I'm struggling with a certain concept. Sometimes the best method is to go through a progression until whatever you're learning clicks.
There are so many options when it comes to learning how to code. There are free online resources like YouTube or freecodecamp. There are low cost options through places like Udemy, and there are subscription sites like Codecademy, Scrimba, or Educative. Finally, there is the option of going to a bootcamp. The options for learning and choosing something that works for you is pretty much endless, and most of these have ways you can try them out for free before taking a big commitment as far as spending money.
"Practice makes perfect." It's something that a lot of us have probably heard throughout the years, but it's amazing how true it is. This is probably the most important aspect of retaining the knowledge that I've learned. Even if I have to do the same boring thing over and over, I know that it just helps me become better at knowing why I'm doing what I'm doing and making sure I understand the concepts of everything I'm applying. I'm a musician in my free time, and it is similar when learning a knew song. Scales are boring, but it is necessary if I want to get better and understanding how to apply it to music. It makes me a better player.
I mentioned earlier that video was helpful in learning CSS. It is true, but there were some concepts that were a bit confusing. It was only when I used knowledge from other parts of CSS that I could apply to learn exactly what I was trying to accomplish. Take CSS Grid for example. I could not visualize, on a blank page, how to layout everything. The thing that helped me most was creating a border around each element so I could see everything in a box. As I started moving everything around, and applying what I was learning, it started to visually make sense. The borders helped me to initially see how I wanted to layout a page. It came from a combination of watching, reading, and doing.
It's easy to get to a place where you want to just give up or scream in frustration while learning something challenging. I feel that it is ok to let frustrations out, maybe take a walk, drink some coffee, and most of all, come back to it later. The key is to not give up. We have all been at a place where it doesn't make sense, but when we stay at it and push through, the reward is great. Good luck on your learning journey!