DEV Community

Jaisurya
Jaisurya

Posted on

Boolean Attributes in HTML

The three of the most common boolean attributes that we use in HTML.

Disabled:
When you add it to a form element, you completely shut down any interaction with it.Form inputs that depend on a previous action. For example, keeping a "Submit" button disabled until the user checks a "Terms of Service" box.

<button type="submit" disabled>Submit Application</button>
Enter fullscreen mode Exit fullscreen mode

Required:
It tells the browser that this field must have a value before the form can be submitted. If a user tries to click submit while a required field is empty, the browser blocks the submission and pops up a native warning message.

<input type="email" name="user_email" required>
Enter fullscreen mode Exit fullscreen mode

**
Readonly:**
The readonly attribute is the most unique of the three and is often confused with disabled.Pre-filled data that the user needs to see (and maybe copy), but shouldn't alter. For example, an order summary page showing a calculated grand total or a system-generated account ID.

<input type="text" name="account_id" value="A99281" readonly>
Enter fullscreen mode Exit fullscreen mode

Top comments (0)