You shouldn’t compare learning HTML and CSS to learning JavaScript, as JavaScript is a programming language, where as HTML and CSS aren’t much more then standards.
Not only do you have to learn the syntax of the language (just like HTML and CSS), but you also have to learn the concepts and ideas behind programming. I’d compare it to playing a board game. At first it might take a while to learn the rules of the game (the syntax), but then you need to learn how to play the game within the constraints of the rules (learning concepts and ideas). Take a game like chess which has slightly complex rules, but basically infinitely complex when it comes to mastering the game. I’m not saying you need to become a “chess master” of programming, but you do want to strive to become good enough to be able to play the game 
So going back to programming let me get a few things out of the way.
-
Programming is hard, if it wasn’t everyone would do it.
-
Your going to get stuck and run into problems, programming is like trying to teach a 3 year old how to accomplish a complex task using a foreign language. The kid is just capable of listening well enough to your instructions as-is but lacks common sense. To make up for it the kid is super duper fast. (baby flash?) Because of this the kid/computer doesn’t really help you, its just “there” taking your instructions as-is. There’s infinite ways to screw this process up, so bugs and issues are to be expected.
The goal isn’t to write perfect code, or become the “perfect developer”, but rather be able to run into a problem and solve it over time. Starting out some problems might take longer then others, but with the amount of resources out there you should be able to figure it out and be able to understand them. I always say fail 500 times and learn 500 new things, rather then just get lucky.
Honestly this feeling will never go away, there is always something dumb, or something once solved will have you going “what the hell was I thinking?”. You can have this feeling on day 1 and on day 1 million. Again its not about not feeling stupid, its about being able to overcome this feeling and solve the problem, it might take a while, or you might need help here and there, but as long as you learn from it and gain the experience your doing fine. 
Keep going at it, struggle, and learn!
Good luck!