<tagname>content</tagname>
The HTML component is everything from the begin tag to the end tag:
<p>My first HTML paragraph.</p>
Start tag | Element content | End tag |
---|---|---|
<h1> | My First Heading | </h1> |
<p> | My first paragraph. | </p> |
<br> |
Nested HTML Elements
HTML components can be settled (components can contain components).
All HTML records comprise of settled HTML components.
This case contains 4 HTML components:
Example
<!DOCTYPE html>
<html>
<body>
<h1>My First Heading</h1>
<p>My first paragraph.</p>
</body>
</html>
<html>
<body>
<h1>My First Heading</h1>
<p>My first paragraph.</p>
</body>
</html>
HTML Example Explained
The <html> component characterizes the entire archive.
It has a begin label <html> and an end tag </html>.
The component substance is another HTML component (the <body> component).
html>
<body>
<h1>My First Heading</h1>
<p>My first paragraph.</p>
</body>
</html>
<body>
<h1>My First Heading</h1>
<p>My first paragraph.</p>
</body>
</html>
The <body> component characterizes the archive body.
It has a begin label <body> and an end tag </body>.
The component substance is two other HTML components (<h1> and <p>)
<body>
<h1>My First Heading</h1>
<p>My first paragraph.</p>
</body>
<h1>My First Heading</h1>
<p>My first paragraph.</p>
</body>
The <h1> element defines a heading.
It has a start tag <h1> and an end tag </h1>.
The element content is: My First Heading.
<h1>My First Heading</h1>
The <p> element defines a paragraph.
It has a start tag <p> and an end tag </p>.
The element content is: My first paragraph.
<p>My first paragraph.</p>
Don't Forget the End Tag
Some HTML elements will display correctly, even if you forget the end tag:
Example
<html>
<body>
<p>This is a paragraph
<p>This is a paragraph
</body>
</html>
<body>
<p>This is a paragraph
<p>This is a paragraph
</body>
</html>
The illustration above works in all programs, in light of the fact that the end tag is viewed as discretionary.
Never depend on this. It may deliver startling results and/or blunders on the off chance that you overlook the end tag.
Empty HTML Elements
HTML components with no substance are called unfilled components.
<br> is an unfilled component without an end tag (the <br> tag characterizes a line break).
Vacant components can be "shut" in the opening tag like this: <br/>.
HTML5 does not oblige unfilled components to be shut. Anyhow on the off chance that you need stricter approval, or you have to make your report comprehensible by XML parsers, you ought to close all HTML components.
HTML Tip: Use Lowercase Tags
HTML labels are not case delicate: <P> implies the same as <p>.
The HTML5 standard does not oblige lowercase labels, but rather W3C suggests lowercase in HTML4, and requests lowercase for stricter archive sorts like XHTML.
No comments:
Post a Comment