Understanding HTML Attributes

Table of contents

No heading

No headings in the article.

In real cases when you have an HTML element on your page, you often want to add more information to the opening tag of that element, you can achieve this with attribute.

Attributes always have the key="value" pair syntax

let's say you want to give a unique identifier to an HTML element, you can do this by adding an id attribute.

<div id="main-content">
    <p>main content</p>
</div>

You can have multiple attributes on an element but not a duplicate.