Slide 1
Slide 2
Slide 3

Boolean Attributes in HTML5 (HTML-V21)

No Comments

  1. Boolean Attributes
    Boolean attributes represent the values true and false and don't need a value with the attribute name.
  • To set the value to true, you simply write the attribute name
  • To set the value to false, you don't write (leave out) the attribute at all

    Commonly used Boolean attributes
        · checked
        · disabled
        · readonly
        · required
        · autofocus
        · multiple

   Source Code:

Copied!
<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Boolean Attributes</title>
</head>
<body>

	<h3>Boolean Attributes</h3>

	<input type="checkbox" checked> Checked<br><br>

	<button onclick="this.disabled=true">Click to Disable</button><br><br>

	<input type="text" value="Readonly" readonly><br><br>

	<form>
	  <input type="text" placeholder="Required" required>
	  <button>Submit</button>
	</form><br>

	<input type="text" placeholder="Autofocus" autofocus><br><br>

	<select multiple>
	  <option>Apple</option>
	  <option>Banana</option>
	  <option>Mango</option>
	</select>

</body>
</html>

Result:

Watch the video:


Ebook:
https://softkhpc.blogspot.com/2026/11/html-tutorial-beginners.html

back to top