Question about spacing elements, and divs



Just completed the 1st HTML lesson. One thing i struggled on was understanding how, or the appropriate spacing when coding new elements.

For example, when coding on a new line, how do I go about spacing correctly? TAB doesn't always line the coding right. Am I supposed to space 2 times? 3 times?

Also, when does the name of a div matter? at the end of lesson 1, We group the 3 headings together and name the div, < div class="learn-more" >

Sorry if my question is confusing. Hoping someone can help! I dont want to develop bad habits!



It's a bit clunky in the editor here at Codecademy, sometimes the default code uses spaces and sometime it uses tabs. I tend to go with tabs here.

The point of spacing is for humans, not the browser, so when you are coding on your own machine or webserver, you will be using a code editor that you can configure to suit yourself or your team's/company's standards. You will be able to set it to auto tab, and you will be able to set it to 2 or 3 or more spaces per tab.

The name of the div doesn't matter to the browser but you should be kind to the other humans reading your code, including yourself. Don't name your divs "Fred" and "Barney". Don't name them "green-background" because when you decide to change that background to orange someday that is going to be really silly looking. Same for something like "left-column". It might sound like a good idea in some cases, but then you decide to move the content to the right, or the bottom. Names that describe the purpose will be more sensible, "nav-bar", "contact_info", "social_media". There is a ton of reading about this on the net.