web analytics
Working with HTML5 Options
@2021-03-16 07:41:28

Handling White Space

A whitespace character is any empty or blank character such as a space, tab, or line break. The browser reading the HTML code ignores the presence of white-space characters between element tags and makes no distinction between spaces, tabs, or line breaks. Thus, a browser will treat the following two pieces of code the same:

<p>Welcome to my website.</p>



Welcome to my website.


The browser also collapses consecutive occurrences of white-space characters into a single occurrence, so that the text of the paragraph in the following code is still treated as “Welcome to my website”, ignoring the extra white spaces between “my”
and “website”.


Welcome to my     website.


The bottom line is that it doesn’t matter how you lay out your HTML code because the browser is only interested in the text content and not how that text is entered. This means you can make your file easier to read by indenting lines and by adding extra white-space characters to separate one code block from another. However, this also means that any formatting you do for the page text to make the code more readable, such as tabs or extra white spaces, is not transferred to the web page.

You must Sign In to comment on this topic.

© 2021 Digcode.com