Line breaks and special characters
Line breaks are essential in writing, don't you think? In HTML, even line breaks have their own tags.
Not only that, but symbols such as > and < are considered special characters. They need to be written in a special way to display on a webpage.
Here, we will talk about line breaks and special characters.
- Paragraphs: the <p> tag
- Emphasis: the <em> tag
- More emphasis: the <strong> tag
- Italic text: the <i> tag Not recommended
- Bold text: the <b> tag Not recommended
- Line breaks: the <br> tag
The <br> tag forces line breaks
Even if you insert a line break in the source code by hitting enter, it will not be a line break when displayed in a browser.
Therefore, you must use a HTML tag to create a line break. This tag is <br>.
This tag is called an empty element because it is not addded with start and end tag pair. It is entirely self-contained.
[Example]
Here's where we will insert a line break. <br> A line break has been inserted.
[Display example]
A line break has been inserted.
Strictly speaking, you're supposed to write <br />, but that's not necessary anymore. So don't sweat it.
Special characters
In HTML, there are some symbols that browsers might not display even if you write them down. For example, < and > are used for parsing HTML tags, so how are you supposed to tell the computer you actually want your visitor to see this?
Characters like this are written in the source code with a format like &XXX;. It looks weird in the code, but your browser shows them totally normal!
Symbol | Code | Symbol | Code | Symbol | Code |
---|---|---|---|---|---|
< | ©< | © | © | ← | ← |
> | > | \ | ¥ | → | → |
" | " | √ | √ | ↑ | ↑ |
& | & | ∞ | ∞ | ↓ | ↓ |
There are many more special characters than this. Check out the list of special characters to learn more.