4. Elements, Tags, and Attributes Explained
These three terms are the foundation of HTML vocabulary.
4.1 Tags
A tag is the specific keyword enclosed in angle brackets (< and >).
- Opening Tag:
<h1> - Closing Tag:
</h1>(Note the forward slash/)
4.2 Elements
An element is the entire structure, including the opening tag, the content, and the closing tag.
html
This is the content of the paragraph element.
Empty Elements (Self-Closing): Some elements don't wrap content and thus don't need a closing tag. Examples include the image tag (<img>) and the line break tag (<br>).
4.3 Attributes
Attributes provide additional information about an element and are placed inside the opening tag. They come in name/value pairs: name="value".
Example using the lang attribute:
We typically add the lang attribute to the <html> tag to declare the language of the document, which helps search engines and screen readers.
html
...Example using id attribute:
html
This is the intro.