Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialMJC Codes
5,656 PointsWhite 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
22,989 PointsIt 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
39,199 Pointsn 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
5,656 PointsThank you both for your replies. I guess I just need to get used to what HTML code looks like. :-)