When inserting spaces in HTML, the default behavior is to display only one space between words no matter how many times you press the spacebar. But what if you want to insert multiple white spaces in HTML? Let's explore how to insert white spaces in HTML as explained below.

Below is the method to insert white spaces in HTML. Let's follow along.
1. Inserting White Spaces in HTML
Typically, HTML will only display a single space between words no matter how many times you hit the spacebar. To insert additional white spaces in HTML, you can use the named entity code or the numeric entity code  
These codes will generate a non-breaking space that prevents line breaks at its position.

Note: It's important not to overuse this character as it can make it difficult for browsers to insert line breaks in an orderly and readable manner. If you need to insert more than one space, consider using the following codes:
2. Inserting Spaces with Greater Width in HTML
In addition to the code for inserting white spaces, you can use the following codes to insert spaces with different widths. These codes do not affect line breaks:
  - inserts a space equivalent to two regular spaces ( ).
  - inserts a space equivalent to four regular spaces ( ).

3. Utilizing Preformatted Text in HTML
Any white spaces or line breaks entered using shortcuts within the <pre> </pre> tags will be displayed exactly as entered.

You can utilize this to display code examples, poetry, or any other text where precise spacing and line breaks are important.
4. Create Line Breaks
Use the <br> tag to end the current line of text. You can create multiple blank lines with multiple br tags.
In addition, you can refer to the following table of commonly used character codes:
Kết Quả |
Mô tả |
Kiểu Tên |
Kiểu Số |
khoảng trắng |
& nbsp ; |
& #160 ; |
|
< |
dấu bé |
& lt ; |
& #60 ; |
> |
dấu lớn |
& gt ; |
& #62 ; |
& |
dấu " và " |
& amp; |
& #38; |
" |
dấu nháy kép |
& quot; |
& #34; |
' |
dấu nháy đơn |
' không hỗ trợ trong IE |
& #39; |
¢ |
Cent |
& cent; |
& #162; |
£ |
pound |
& pound; |
& #163; |
¥ |
yên |
& yen; |
& #165; |
€ |
Euro |
& euro; |
& #8364; |
§ |
section |
& sec; |
& #167; |
© |
Copy |
& copy; |
& #169; |
® |
registered trademark |
& reg; |
& #174; |
× |
multiplication |
& times; |
& #215; |
÷ |
division |
& divide; |
& #147; |
Above, the article has shared with you various code options for inserting white spaces in HTML. You can choose the appropriate code to insert white spaces. We hope this article will be helpful to you in your HTML learning journey. Wishing you success!