WEB DEVELOPER SITE
HTMLCSSJAVASCRIPTSQLPHPBOOTSTRAPJQUERYANGULARXML
 

HTML Elements


In this chapter we learn html elements.

All HTML documents are made up by HTML elements.


HTML Elements

HTML components are composed with a start tag, with a end tag, with the content in between:

<tagname>content</tagname>

The HTML element is everything from the begin tag to the end tag:

<p>My first HTML paragraph.</p> <p>MY FIRST HTML PARARAGRAPH.</p>
Start tag Element content End tag
<h1> My First Heading </h1>
<p> My first paragraph. </p>
<br> break    

Nested HTML Elements

HTML components can be settled (components can contain elements).

All HTML records comprise of settled HTML elements.

This precedent contains 4 HTML elements:

Example

<!DOCTYPE html>
<html>
<body>

<h1>My First Heading</h1>
<p>My first paragraph.</p>

</body>
</html>
Try it yourself »

HTML Example Explained

The <html> component characterizes the whole document.

It has a start tag <html> and a end tag </html>.

The component content is another HTML component (the <body> element).

<html>
<body>

<h1>My First Heading</h1>
<p>My first paragraph.</p>

</body>
</html>

The <body> component characterizes the document body.

It has a start tag <body> and a end tag </body>.

The component content is two other HTML components (<h1> and <p>).

<body>

<h1>My First Heading</h1>
<p>My first paragraph.</p>

</body>

The <h1> component characterizes a heading.

It has a start tag <h1> and an end tag </h1>.

The component content is: My First Heading.

<h1>My First Heading</h1>

The <p> component characterizes a paragraph.

It has a start tag <p> and an end tag </p>.

The component content is: My first paragraph.

<p>My first paragraph.</p>

Don't Forget the End Tag

Some HTML components will show effectively, regardless of whether you overlook the end tag:

Example

<html>
<body>

<p>This is a paragraph
<p>This is a paragraph

</body>
</html>
Try it yourself »

The precedent above works in all programs, in light of the fact that the end tag is viewed as discretionary.

Never depend on this. It may create sudden outcomes and additionally mistakes in the event that you overlook the end tag.


Empty HTML Elements

HTML components with no substance are called void elements.

<br> is an unfilled component without an end tag (the <br> tag characterizes a line break).

Empty components can be "closed" in the opening label this way: <br/>.

HTML5 does not require void components to be shut. However, on the off chance that you need stricter approval, or you have to make your record comprehensible by XML parsers, you should close all HTML elements.


HTML Tip: Use Lowercase Tags

HTML labels are not case delicate: <P> implies equivalent to <p>.

The HTML5 standard does not require lowercase labels, yet W3C recommends lowercase in HTML4, and demands lowercase for stricter report types like XHTML.