When it comes to HTML:
Get all your content written before you try to style it...
...but have an idea of what style you want before you start.
If you have a rough idea in your head of how you want your finished page to look, you'll have a much easier time creating your structure. Having to go back and reorganise an entire HTML doc into divs and sections and whatnot is a real trial, and one of the leading causes of breaking your code. If you're dividing up your content properly as you go, it also helps to create some classes for structural elements you're going to use a lot - e.g, creating columns etc - to save yourself some time later
Use all the tools available...
...Nobody will give you a prize for struggling alone.
Don't write code in a plain text editor, use one that will auto-fill element tags as you write, and flag mistakes. It's sort of pointless to memorise all the meta and head tags a page needs, so don't. Write them once, and save them as a blank boilerplate. Or use one of the thousands available free online. If your page doesn't look right, and you can't see your mistake, run your code through a validator. No point spending an hour painstakingly reviewing your code line-by-line, checking that all the tags are correctly nested, indented and closed, when you can immediately find the orphaned closing tag in seconds with a validator. Save your time and brainpower for writing code.
CSS, on the other hand:
Start general...
...Then get specific
If you start by trying to style your really finicky columns with alternating fonts and colours before setting the main document's properties, all you're going to do is repeat yourself. If you want most things to have the same font, color and padding, set this as high up in the document as you can - if not the body, then a tag like Header or Main. Then work your way down the page
Padding and margins...
...The invisible expanders
It's super annoying when you have a div that just won't go where it's told. If you've set the width, and told it how to float, and fiddled with the text alignment, and it still isn't behaving, then you probably need to sort out the margins or the padding. The browser console is your friend for seeing what margins are being applied - this'll show you where the real edges of your element are, and let you play until you know what changes to make.
And in general:
Don't aim for perfection right away...
...Do it right first, then do it nice.
You're not going to write perfect, lightweight and elegant code straight off the bat. Focus on getting your page to look how you want it to look first of all, then tidy up your code. Sure, writing your margin properties on one line is best, but if you need to write each side on a new line first of all, just to make sure you're doing it right, then do that.
Good coders borrow...
...Great coders steal
T.S. Eliot may or may not have been serious when he said this about writing, but it doesn't mean we can't take it to heart. If you want to make your page look a certain way, but haven't a clue how to go about it, find a page that already looks that way. Inspect the elements and see what styles are being applied, then tweak that code to work with your content. Then, next time, you'll know what to do.
Always ask for help if you need it...
...From whoever you can
If you have a problem you can't solve, google it. Chances are, someone else has had the same problem, and has been told how to solve it already. Stack Overflow, Github, and other coder forums are great resources. You might feel that your question is basic, but who cares? Everyone answering will, at one point, have needed to ask the same question. If it truly is easy, you'll find a solution in no time, and be a little wiser than you were before. But if it's a tricksy little problem, then there's even less reason to feel defeated.
Comment, comment, and comment some more...
...Future you will thank you.
Even now, as a relatively novice developer, I'm finding comments insanely useful. "I'm the only one who reads or edits the code I'm writing, so what's the point in commenting? I know what I've written!"
This is what I used to think to myself, and I'm glad that tutorials have stressed that it's not good practice to write no comments. Even a short page can have a hell of a lot of code, and it can be hard to see, at a glance, where you are and what it's doing. Using comments to divide up your CSS, and to preface HTML sections with a heading that stands out and is easy to read makes finding that one line you want to change much, much easier.
Hopefully, this will be useful to you
It is all certainly advice that others have given me, or things that I find useful to remember as I'm coding. I'm still new to this, so I'm forever making new mistakes, but I hope that I'm learning from them.