Optional HTML tags
It turns out that in HTML, some start tag or end tag are optional. This makes it very convenient when writing HTML manually. You can learn more by reading the specification on optional tags.
- The
html
's start and end tags may be omitted - A
head
's start and end tags may be omitted - A
body
's start and end tags may be omitted
Here's an example of a valid HTML5 document:
<!DOCTYPE HTML>
<title>Hello</title>
<p>Welcome to this example.
Self-closing elements
Here are some frequently used elements from which we can omit the end tag:
- The
p
element - The
li
element - Table elements
Example
This is an example.
- That's the first point
- That's the second point
Readbility | 100 |
Fun | 100 |
<p>This is an example.
<ul>
<li>That's the first point
<li>That's the second point
</ul>
<table>
<tr>
<td>Readbility <td>100
<tr>
<td>Fun <td>100
</table>