HTML Elements / Tags
Elements are commonly referred to as tags and are instructions that are
placed directly into the code of an HTML document. Each HTML tag tells the
browser that it should do something specific and not simply display the text. In
HTML, the tags begin with [<] and end with [>].
There are two types of HTML Tags.
- Tags that require a closing tag.
- Tags that do not require a closing tag.
For explanation and simplicity I will refer to the tags that require a closing tag as a companion tag. For the tags that do not require a closing tag I will refer to them as a singular tag.
Companion Tags:
In Companion tags, the first tag is referred to as the Opening Tag and the second tag is referred to as the Closing Tag. The closing tag requires the addition of a slash [ / ], this tells the browser that the specified opening tag should now be closed.
Example of text placed inside a paragraph:
<p>Once upon a time in a galaxy far far away.</p>.
Explained: The browser sees an opening paragraph tag, <p> displays the text and
then sees a closing paragraph tag </p>.
When entering companion tags onto the page you must close the tags in the opposite order you open them. There is no set order for these tags with the exception that the paragraph needs to be the first one opened and the last one closed.
Example code of text sized to "2" and italicized;
<p><font-size="2"><i>Text
styled
</i></font></p>
As you can see, we open our paragraph, open the font size, and then open italic. We placed our text and then closed the italic, closed the font size and lastly closed the paragraph.
Singular Tags:
A Singular tag does not have a closing tag.
Example : <br> (line break) , <hr> (horizontal rule) These tags do not require a closing tag.