Menu

HTML Tags, Elements and Attributes Explained

HTML Tags, Elements and Attributes Explained

These three words get mixed up a lot, so let's separate them clearly.

A tag is code wrapped in angle brackets, like <p> or <h1>. Most tags come in pairs, an opening tag and a closing tag, with a forward slash in the closing one.

An element is the tag plus everything inside it, including the closing tag. So <p>Hello</p> as a whole is called an element.

An attribute gives extra information about an element. It always sits inside the opening tag and usually comes as a name and value pair.

<a href="https://example.com" target="_blank">Visit Site</a>

Explanation:

Here, ‘a’ is the tag name. The entire line, including the closing tag, is the element. href and target are attributes.

href tells the browser where to go, and target tells it to open the link in a new tab.


HTML Tutorial (From Basics to Implementation)

AP

Abhishek Pati





Get in Touch For Details