HTML Syntax

HTML is fairly easy to learn, because of its simple syntax.

HTML is all about tags, and I am sure that you know what a tag is!

<p> is a tag, it starts with "<" and ends with "\>", and the tag name in-between. "p" is the tag name in this case.

There are two types of tags:

  1. Opening tags

  2. Closing tags

<p> is an opening tag. </p> is a closing tag. The closing tag is just with a "/" after "<".

So, first, there is an opening tag, then the closing tag, and the content in between. Like "<p> Learning HTML </p>".

And finally, there comes the element.

Element = Opening tag + content + closing tag

But keep in mind that, the closing tag is not always there. Some elements do not need a closing tag, which are known as self-closing tags.

Here are some more examples of elements.

<p>Learning HTML</p>
<h1>Learning HTML</h1>
<pre>Learning HTML</pre>

Elements can also be nested! Even most HTML document contains a whole bunch of nested elements.

<p>Learning <b>HTML</b></p>

Above is an example of nested HTML elements.

That's all for today! Thank you very much for reading.