The basic building blocks of an HTML document are,
- Tags: An HTML tag is written between < and > brackets and acts as a container for different types of content. Each tag has its own specific meaning, and the same applies to the content within it.
- Attributes: To provide some extra information about a particular element, attributes are used in an HTML document. An attribute is applied within the start tag of a particular element and contains two fields: name & value.
- Elements: An element in an HTML document can be understood as an individual component of an HTML file. In more simple words, the elements are everything written within tags, including the tags, attributes, and contents.
Syntax:
<tag name attribute_name= " attr_value"> content </ tag name>
Example:
<!DOCTYPE> <html> <head> <title>Example</title> </head> <body> <h1 style="color: red">Hello</h1> <p style="color: blue">World!!</p> </body> </html>
Explanation:
Here, style is an attribute of both the h1 and p tags.