Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

HTML Build a Simple Website Text Editors and HTML Images and Lists

MJC Codes
MJC Codes
5,656 Points

White space?

CS student here, wanting to learn HTML.

How do browsers handle white space in HTML? I know C++ compilers don't care and that in Python white space matters. How about HTML?

3 Answers

Logan R
Logan R
22,989 Points

It can depend. If there is white space in between < and >, it shouldn't matter, but it can make it harder to read. In between words, if you double space, triple space, etc, it will just remove all but one space.

The only thing you have to watch out for is white space in between commands and commands/words. It can sometimes mess up the padding and so forth.

Hope this makes sense :)

James Barnett
James Barnett
39,199 Points

n most cases whitespace is ignored in HTML with a few edge cases. HTML isn't exactly a programming language for instance there is no such thing as an error in HTML, it will just parse it as best it can.

If you have a specific question post your code we should be able to give you a more specific answer.

Python is somewhat unusual among major programming languages in it's semantically significant whitespace.

MJC Codes
MJC Codes
5,656 Points

Thank you both for your replies. I guess I just need to get used to what HTML code looks like. :-)