HTML Tutorials - Herong's Tutorial Examples - Version 2.20, by Dr. Herong Yang
Opening and Closing Tags of Elements
This section describes the syntax of entering opening tags and closing tags to create HTML elements. It's better to have all elements closed explicitly with closing tags.
HTML documents are made up by a collection of nested HTML elements. Each element has a required opening tag and an optional closing tag. Here are some basic guidelines on how to enter HTML tags to create HTML elements.
1. Each HTML element must start with an opening tag in the format of:
2. An HTML element that supports content must have the content immediately following the opening tag like this:
3. An HTML element that supports content must have a closing tag or let the browser to determine where is the end. It is strongly recommended that you always provide closing tags yourself like this:
4. An HTML elements that does not support content must have no closing tag or combine the opening tag and closing tag into a short-hand format. It is strongly recommended that you always use the short-hand format like this:
5. HTML element tag names are case insensitive. For example, "body" and "BODY" are identical. It is strongly recommended that you always use lower case letters in tag names.
Here is a good example of HTML document that have some elements without closing tags and some with closing tags:
<!DOCTYPE html> <!-- HTML_Opening_and_Closing_Tags.html - Copyright (c) HerongYang.com. All Rights Reserved. --> <html> <head> <meta charset="iso-8859-1"> <title>Opening and Closing Tags</title> </head> <body> <!-- HTML elements with no closing tags --> <p>Tags are used to delimit the start and end of elements in the markup. <hr> <!-- HTML elements with closing tags --> <p>Tags are used to delimit the start and end of elements in the markup.</p> <hr/> </body> </html>
Table of Contents