Hi, @izaakx. That’s a pretty broad question…
Are you talking about just in Codecademy, or in building your own websites? If I knew that, I could possibly give you some more answers.
Some general tips I can give you would be:
Make sure your code is always aligned properly. If your code flows evenly, it will be easier to read. Also, you can break down your code lines, even temporarily, to make it easier to read.
Example for HTML:
You have:
<p>This paragraph has a <b>short <a href="#">link.</a></b></p>
While this is technically correct, it’s a little confusing because of all the tags in it. So if you’re trying to debug it, it might help to break it down like this while you’re working with it:
<p>
This paragraph has a
<b>
short
<a href="#">
link.
</a>
</b>
</p>
In that example, having the one line of text broken down over multiple lines makes it easier to see that, yes, the opening p tag has a closing p tag, the opening b tag has a closing b tag, and the a tag is written properly, with the href in the correct place.
For CSS, I would advise keeping all rules of similar types grouped together. Even for a single element, keep all margin instructions with the other margin instructions, all color instructions with the other color instructions, etc.
Suppose you have:
.special-class {
margin-top: 20px;
color: red;
font-family: Georgia;
}
Now you want to add some margin to the bottom, too. Better not go tacking it on at the bottom of the above code. While that would work just fine, it would be disorganized and make your code difficult for a human (i.e. you) to read, and even if you know everything you need to about how the code works, getting messy will only confuse you later. So you would add another line right below margin-top.
.special-class {
margin-top: 20px;
margin-bottom: 25px;
color: red;
font-family: Georgia;
}
This logical progression makes for a more readable set of rules.
•••
Always take the error in the context of the code around it. Your browser might throw you an error message saying that the problem lies in line 16. Let’s say you study line 16 of your code carefully, and it looks like there’s nothing wrong with it. Well, then why does it say the error is on line 16? Perhaps you forgot to close line 15 properly–a missing closing paragraph tag in your HTML, a missing semicolon in your CSS–something like that. Sometimes, the browser error message does not always get it quite right.
•••
You are likely already doing this, but…If you cannot pinpoint the issue quickly, read your entire code, top to bottom, slowly and patiently, thinking to yourself as you read each line, “Does this line make sense by itself? Does this line make sense with the rest of the code?” Yes, this is a boring and frustrating process, but most often rewarding in the end.
•••
Wow, that was a long answer!
I hope it helps you some, and if you can give me more specifics–like whether you’re just needing help inside Codecademy or with building stuff on your own–I might be able to help some more (if you feel like reading another book, haha).
Phoenix