HTML Elements
An HTML element is everything from the start tag to the end tag:
Start tag * | Element content | End tag * |
---|---|---|
<p> | This is a paragraph | </p> |
<a href="default.htm"> | This is a link | </a> |
The start tag(eg <p>) is called opening tag and the end tag(eg </p>) is called closing tag.
Nested HTML Elements
Most HTML elements can be nested (can contain other HTML elements).
HTML documents consist of nested HTML elements.
Example :
<!DOCTYPE html>
<html>
<body>
<p>This is my first paragraph.</p>
</body>
</html>
<html>
<body>
<p>This is my first paragraph.</p>
</body>
</html>
The <p> element:
<p>This is my first paragraph.</p>
The <p> element defines a paragraph in the HTML document.
The element has a start tag <p> and an end tag </p>.
The element content is: This is my first paragraph.
The element has a start tag <p> and an end tag </p>.
The element content is: This is my first paragraph.
The <body> element:
<body>
<p>This is my first paragraph.</p>
</body>
<p>This is my first paragraph.</p>
</body>
The <body> element defines the body of the HTML document.
The element has a start tag <body> and an end tag </body>.
The element content is another HTML element (a p element).
The element has a start tag <body> and an end tag </body>.
The element content is another HTML element (a p element).
The <html> element:
<html>
<body>
<p>This is my first paragraph.</p>
</body>
</html>
<body>
<p>This is my first paragraph.</p>
</body>
</html>
The <html> element defines the whole HTML document.
The element has a start tag <html> and an end tag </html>.
The element content is another HTML element (the body element).
The element has a start tag <html> and an end tag </html>.
The element content is another HTML element (the body element).
Don't Forget the End Tag
Some browsers like Crome may display your content even if you have not used the end tag but its not the case with others. Old browsers like IE 8 may report an error if you have not used the end tag.
EXAMPLE:
<p>This is a paragraph
<p>This is a paragraph
<p>This is a paragraph
Empty HTML Elements
HTML elements with no content are called empty elements.
For example, <br> is an element without a closing tag.
<br> is called break and is used to give space.
HTML Tip: Use Lowercase Tags
HTML tags are not case sensitive: <P> means the same as <p>. Many web sites use uppercase HTML tags.
No comments:
Post a Comment