Properly formatting code

I’m learning HTML and CSS and I feel a little overwhelmed when I write code. I’m completely self-taught prior to starting freeCodeCamp, so please be kind. :slight_smile:

Can anyone suggest resources about how to format code so that it is readable by other people? I want to form good habits now.

Things I second-guess myself about:

  • When/how much to indent lines
  • When to write code as a single line vs a multi-line block, and where line breaks should go
  • When to include comments explaining code
  • What order to write things like html attributes and css properties in

Thank you!

Those are good questions. You can do a search for something like html properly formatting code and get back a lot of good information.

If you use codepen to start writing the first projects in each of the HTML, CSS and JS editors you’ll see a chevron in the upper right. When you expand them there is a link to click to format.
Codepen also has a setting you can turn on that will format on save.

If you use an IDE like VSCode, Brackets, Atom, et cetera there is usually a plug-in you can install that will format your code with a single click.

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.