HTML Attributes

HTML elements allow attributes, which provide additional information about the element.

Attributes must be defined in the opening tag, using name/value pairs like name="value".

W3C recommends lower case attribute names, though they are not case sensitive.

Always use quotes for attribute values, either single or double quotes, and single quotes are helpful when the value itself contains quotes.

<html lang="en">
<a href="https://randomcodez.com">Random Codez</a>
<p title='About "Random Codez" website'>Random Codez</p>
<img src="random.png" alt="brand" width="200" height="300">

Examples

<!DOCTYPE html>
<html lang="en">
<head>
</head>
<body>
    <h1>HTML Attributes</h1>
    <p style="color:red;" title="tooltip text">Paragraph text here..</p>
    <a href="https://randomcodez.com">link</a>
    <img src="random.png" alt="brand" width="200" height="300">
</body>
</html>

NOTE: HTML5 Attributes Guide lists all the attributes and their description and tags that allow them.

Overall

HTML attributes help us provide additional information about an element.