Do Not Forget The END TAG
In HTML5 it is not strictly necessary to close certain HTML tags.
The tags that aren’t required to have specific closing tags are called “self closing” tags.
What is a self closing tag? An example of a self closing tag is something like a
line break (<br />) or the meta tag (<meta>). This means that the following are both acceptable:
<meta charset="UTF-8">
and
<meta charset="UTF-8" />
Some closing tags are optional, however. The tags are optional because it’s implied that a
new tag would not be able to be started without closing it. These are the following:
html, head, body, p, dt, dd, li, option, thead, th, tbody, tr, td, tfoot, colgroup.
There are also tags that are forbidden to be closed: img, input, br, hr, meta, etc.
The question is: should tags that are optional be closed? Code with closing tags is
much more readable and easy to follow. It is much easier to visually inspect a page
with well laid out markup. Working with this markup is easier for developers.
Some HTML elements will display correctly, even if you the forget the end tag :
Example
<!DOCTYPE html>
<html>
<head>
<title>Do Not Forgot The End Tag</title>
</head>
<body>
<h1>This is my heading.
<p>This is my first paragraph.
</body>
</html>
The example works in all browser, because the closing tag is considered optional.
NOTE: Never rely on this. it might produces unexpected results and/ or errors if you forget the End Tag.
Use Lowercase Tags
HTML Tags are not case sensitive:
Like <p> means the same as <P>
Like <h1> means the same as <H1>
The HTML5 standard does not require lowercase tags, but we recommends
lowercase in HTML, and demands lowercase for stricter document types like XHTML.
Upper case A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Lower case a b c d e f g h i j k l m n o p q r s t u v w x y z
0 comments:
Post a Comment
For Any Tech Updates, Hacking News, Internet, Computer, Technology and related to IT Field Articles Follow Our Blog.