HTML & CSS IntroductionChapter 3. HTML Basics

Space, Line-break and Tag in Content

HTML & CSS Introduction
Course Content

Space, Line-break and Tag in Content

In HTML, some characters and line breaks are not recognized in the content part of the HTML element. Those characters are called reserved characters. In this section, we'll explain the important ones. When you want to use a reserved character or line break in the content part, you need to use replacements that are often called escape characters.

Space

HTML doesn't recognize more than one space. Even if you hit multiple spaces, when you open the HTML document with a browser, you won't see more than one space.

For example, the code below has multiple spaces under the <p> tag; however, the multiple spaces are not rendered in a browser.

How multiple spaces in a HTML document are displayed in a browser

To add multiple spaces, you can use &nbsp; (a non-breaking space) like in the example below.

How non-breaking space works

Line break

HTML doesn't recognize a line break either. For example, the code below has two line breaks; however, the line breaks are not rendered in the browser.

How line-breaks in a HTML document are displayed in a browser

To add a line break, you can use the <br> tag like shown in the example below.

How the br tag works

< > (Tag)

HTML recognizes < and > as an HTML tag. Thus, when you use < > as content, it won't be rendered in a browser like in the example below.

How left and right angle brackets are displayed in a browser

When you want to use < > in your content, you need to use &lt; (less-than) for < and &gt; (greater-than) for > like in the example below.

How HTML entities for the angle brackets work