Back to subject
HTML5/HTML Attributes

Read an Opening Tag

Practical lesson

Let's inspect attributes as small pieces of extra information attached to an HTML element.

- Start with an element such as <a>. The element name says what it is. - Add href="https://example.com". href is an attribute name and the URL is its value. - Add title="Visit Example" to see another common attribute. - Attribute values are normally written inside quotation marks. - Different elements support different attributes because each attribute has a particular job. - Some attributes are boolean, such as disabled or required. Their presence can be enough to turn the setting on. - Global attributes such as id, class, lang, title, hidden, and data-* can be useful across many element types. - Read the opening tag carefully: attributes belong inside the opening tag, before the closing >. - Do not invent random attribute names and expect the browser to understand them. Use standard HTML attributes or the documented data-* pattern for custom data.

The key lesson is that an element tells you what something is, while attributes add extra information or behavior.

Try it yourself
Code

Starter example

Code
<a href="about.html" target="_blank">About</a>
<img src="cat.jpg" alt="A small cat" width="300">
<input type="email" required>
Live preview