Does code indenting matter?

Wednesday, August 16, 2017 - 13:59

Yes, code indenting matters. In some languages your proper indentation of code will affect whether or not your code works as expected. HTML and CSS are not this strict, but indenting still matters. It is recommended to get into the practice of indenting sub elements of code, meaning, as you know by now the <head> section of your HTML is inside of your <html> section, so the <head> should be indented one tab space in, like so:

<html>
<head>...

This is good practice because you want to always be writing clean code that is properly structured. This also helps in troubleshooting your code. For example, what is wrong with this code?

<!DOCTYPE
html><html><head><title>Title of the document<title>
</head><body>
The content of the document.</body></html>

It's hard to tell, right? Now look at the same code properly formatted with clean structure. Of course, now the error is highlighted in orange, but you get the point.

Clean code is also important for working on a team. If you hand off messy code to another designer, developer, or programmer on your team at work, you'll hear about it! Code indenting is good practice and it takes no extra effort. So start doing it now. You'll be glad later.

Openwebby, Sustainable Web Ecosystems, Research Building Education, and all content of this website are registered trademarks of openwebby and Greg O'Toole. All rights reserved.Logo derived from Earth by Nikki Rodriguez from The Noun Project. Font is Montserrat by Julieta Ulanovsky.