HTML whitespace


#1

Could you help me how to put whitespace code well?


#2

Hi @imeldafr,

Whitespace just mean any empty spaces.

Something like:

<html>
    <body>
          <p>          this in between is filled with whitespaces              </p>
    </body>
</html>

Whitespace could also mean indentation as well, so without whitespace (or indentation):

<html>
<head></head>
<body>
<p></p>
</body>
</html>

With whitespace (or indentation):

<html>
   <head></head>
   <body>
       <p></p>
   </body>
</html>

HTML generally will ignore whitespaces but with certain exceptions. Whitespace usually helps with keeping the code organized and easy to read or look at.


For more in-depth reading about whitespace, refer:

But the answers are quite elaborate for beginners, just take it for now that white space generally does not matter much in HTML until you reach to a more advance level.


If you’re thinking to insert whitespace so that HTML does not ignore white space, you may refer this:


#3

If you’re asking this for your exercises or having trouble with your exercises, it is good to provide a link towards the exercise, what error message the exercise says, and your code.

Other than that, I will leave some links about whitespace (questions asked and answered by other users in the community) which I find a good read: :slight_smile:

Help with HTML lesson 11, Whitespacing
Whitespace
When is white space important in HTML/CSS?


#4

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