Chapter 3. HTML Basics

Space, Line-break and Tag in Content

Space, Line-break and Tag in Content
Tag:

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.

Space-Line-break-and-Tag-in-Content

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

Space-Line-break-and-Tag-in-Content

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.

Space-Line-break-and-Tag-in-Content

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

Space-Line-break-and-Tag-in-Content

< > (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.

Space-Line-break-and-Tag-in-Content

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.

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.

Space-Line-break-and-Tag-in-Content

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

Space-Line-break-and-Tag-in-Content

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.

Space-Line-break-and-Tag-in-Content

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

Space-Line-break-and-Tag-in-Content

< > (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.

Space-Line-break-and-Tag-in-Content

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.

Space-Line-break-and-Tag-in-Content

Tag: