Never appeal to my ego this obviously, or else I’ll spew 500 words of text at you too
1.) I’m not actually— wait, hold up, I’m tired of starting shit with numbers.
A.) I’m not actually all that expert. There are significant, crippling gaps in my knowledge. (DOM manipulation? The precedence rules of the CSS cascade?? Anything involving forms???) I shim around these gaps by very carefully writing only about topics I know from top to bottom. Bloviating about a topic you know poorly is all well and good in personal conversation, but it gets you into trouble on the public internet.
(Learn well the lesson of Walter Bright! (Walter Bright is a programmer of great technical skill and mild managerial incompetence, most widely known for the D programming language.) If you find yourself arguing with a domain expert on the subject of their specialty, then you are making a mistake.
This is generally known as “engineer’s disease”, where an extremely intelligent person assumes that their narrow specialist expertise can be generalized to all forms of human knowledge.
You could make a plausible case for calling Walter Bright the world’s greatest systems programmer. Walter Bright is not, however, the world’s greatest civil engineer, and when he finds himself in a technical argument with one, he keeps arguing! The correct action here is to admit that you are not actually omniscient, and gaps exist in your knowledge, but this does not appear to be something Walter can do.)
You will notice that I’m not nitpicking, say, fasntnig’s theme. That’s because fasntnig probably knows more about CSS than I do, and I’d look like a moron doing it.
B.) The biggest secret of web development is that it’s all public. Want to know how HTML works? Just read the spec. Want to know how CSS works? Just read the spec. (Though the CSS 2.1 spec is written by the W3C, so it’s not nearly as witty as the WHATWG HTML5 spec.) Want to know what the W3C considers best practices? They’ll tell you. Want to read a style guide written by the inventor of HTML, 20 years ago? No problem.
If your kung-fu is not quite that strong, then you can read Dive Into HTML5. It’s Creative Commons licensed, so it’s free and clear— free and clear enough to survive the author committing infocide.
Google also has tutorials. So does Mozilla. So does Opera.
C.) The other secret weapon is Google Chrome’s dev tools. Being able to directly edit the live DOM makes shit so easy, you don’t even know. It’s fucking incredible. You can toggle CSS rules, edit them, inspect the bounding boxes of blocks, it’s great. (Edit: hey, check out this post too.)
D.) Forgot to say this earlier, but, W3Schools sucks. Don’t trust em, they’re awful.
F.) I suspect you’ve confused my habit of linking to obscure, decade-old blog posts with deep technical knowledge. (You might notice I’ve done it three times so far, in this post alone.) (Trivia: this post’s title comes from a 2001 jwz post about web design.) (Four times.)
This is more a stylistic flourish than anything substantial, but I highly recommend it, since it makes you look super smart. Bad news: it requires you to have spent 8 hours a day reading stuff on the internet for the last ten years or so, and remembering enough about each article you read to be able to find it again.
So, to answer your question: Yes, years of dedication, and an absolute shitload of reading. Unless you want to wuss out and just learn HTML/CSS.
Wow this ended up long. I better publish it publicly.