Kanbritech Learn logo
HTML HTML Tutorial 45h track

HTML Attributes

Create an email input that must be filled in and give it a label.

Understand the topic

Attributes provide extra information or settings on an opening tag. Some contain values, such as href, lang, and title. Boolean attributes represent on/off states through their presence, such as disabled or required. Global attributes are available on most elements; other attributes only apply to particular elements. Quote values to make spaces and special characters unambiguous.

Worked example

<a href="https://example.com" title="Visit the example site">Example site</a>
<button type="button" disabled>Registration closed</button>

href determines the link destination. type describes button behavior. disabled is a boolean attribute: disabled="false" would still disable the button because the attribute is present.

Practice

Create an email input that must be filled in and give it a label.

Show a suggested answer
<label for="email">Email</label>
<input id="email" name="email" type="email" required>

Common mistake

An attribute is not a CSS property. For example, color usually belongs in a stylesheet rather than as an invented attribute on a paragraph.

HTML documentation

Live Example

Try Coding

Result