Do you need to indent when writing HTML code?

Updated: 01/24/2018 by Computer Hope
indent
Note

This document is discussing indenting HTML code and not how to indent text on a web page.

No. HTML code does not need to be indented, and all browsers and search engines ignore indentation and extra spacing. However, for any human reader it is a good idea to indent your text because it makes the code easier to scan and read. If you or anyone else edits your web page when looking at the HTML code, it is a good idea to do some form of indentation. If you only use a WYSIWYG editor to modify your web page indentation may not be as important.

Tip

If you are using an HTML editor, all editors allow you to clean up or format your HTML. Using this feature can help clean up the code of any web page that is hard to read.

How to clean up HTML code

Adobe Dreamweaver

Click Commands and then Apply Source Formatting.

Microsoft Expression Web

In the HTML view right-click anywhere and choose Reformat HTML.

I want to indent, how should I indent my source?

There is no standard or rule on how you should indent your code. Some people indent their code with one or more space, and others indent their code with the Tab key. Regardless of how you decide to indent your code it is important that you, others, and the editors you use have all the same rules for indenting your code.

Why do some pages have no indentation?

Today, many pages use CMS or other scripts to generate the HTML code that may not be indenting the code when created. Also, some websites may compact or compress their HTML code to help reduce the size of the file to reduce bandwidth and increase the download speed.

Additional information