{"id":9349,"date":"2022-10-06T05:03:35","date_gmt":"2022-10-06T05:03:35","guid":{"rendered":"https:\/\/mdr.foobrdigital.com\/?p=9349"},"modified":"2022-10-06T05:03:35","modified_gmt":"2022-10-06T05:03:35","slug":"html-disabled-attribute","status":"publish","type":"post","link":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/2022\/10\/06\/html-disabled-attribute\/","title":{"rendered":"HTML disabled Attribute"},"content":{"rendered":"\n<p>The HTML&nbsp;disabled&nbsp;attribute is a boolean attribute and specifies that the element must be disabled.<\/p>\n\n\n\n<p>This attribute can be used to prevent using the element until some condition has been met, such as selecting a checkbox. When present, the element does not respond to user actions and cannot be focused. Then, it is possible to make the element usable again, removing the disabled value by JavaScript. The&nbsp;disabled&nbsp;attribute is commonly grayed out.<\/p>\n\n\n\n<p>You can use the\u00a0disabled\u00a0attribute on the following elements:\u00a0&lt;button>,\u00a0&lt;fieldset>,\u00a0&lt;input>,\u00a0&lt;optgroup>,\u00a0&lt;option>,\u00a0&lt;select>, and\u00a0&lt;textarea>.<\/p>\n\n\n\n<p>When the\u00a0disabled\u00a0attribute is applied to an element, the\u00a0:disabled\u00a0pseudo-class also applies to it. The elements supporting the\u00a0disabled\u00a0attribute but not having the attribute set match the\u00a0:enabled\u00a0pseudo-class.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"syntax-2\">Syntax<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;tag disabled&gt;&lt;\/tag&gt;<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"example-of-the-html-span-class-attribute-disabled-span-attribute-used-on-the-lt-button-gt-element-4\">Example of the HTML&nbsp;disabled&nbsp;attribute used on the &lt;button&gt; element:<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;!DOCTYPE html&gt;\n&lt;html&gt;\n  &lt;head&gt;\n    &lt;title&gt;Title of the document&lt;\/title&gt;\n  &lt;\/head&gt;\n  &lt;body&gt;\n    &lt;button type=\"button\"&gt;Button&lt;\/button&gt; &lt;br&gt;&lt;br&gt;\n    &lt;button type=\"button\" disabled&gt;Disabled button&lt;\/button&gt;\n  &lt;\/body&gt;\n&lt;\/html&gt;<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"example-of-the-html-span-class-attribute-disabled-span-attribute-used-on-the-lt-fieldset-gt-element-6\">Example of the HTML&nbsp;disabled&nbsp;attribute used on the &lt;fieldset&gt; element:<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;!DOCTYPE html&gt;\n&lt;html&gt;\n  &lt;head&gt;\n    &lt;title&gt;Title of the document&lt;\/title&gt;\n    &lt;style&gt;\n      div {\n        margin-bottom: 10px;\n      }\n      label {\n        display: inline-block;\n        width: 120px;\n      }\n      fieldset {\n        background: #e1eff2;\n      }\n      legend {\n        padding: 20px 0;\n        font-size: 22px;\n      }\n    &lt;\/style&gt;\n  &lt;\/head&gt;\n  &lt;body&gt;\n    &lt;form&gt;\n      &lt;fieldset disabled&gt;\n        &lt;legend&gt;Personal Information:&lt;\/legend&gt;\n        &lt;div&gt;\n          &lt;label&gt;First Name:&lt;\/label&gt;\n          &lt;input type=\"text\"&gt;\n        &lt;\/div&gt;\n        &lt;div&gt;\n          &lt;label&gt;Last Name:&lt;\/label&gt;\n          &lt;input type=\"text\"&gt;\n        &lt;\/div&gt;\n        &lt;div&gt;\n          &lt;label&gt;Date of birth:&lt;\/label&gt;\n          &lt;input type=\"text\"&gt;\n        &lt;\/div&gt;\n      &lt;\/fieldset&gt;\n    &lt;\/form&gt;\n  &lt;\/body&gt;\n&lt;\/html&gt;<\/code><\/pre>\n\n\n\n<p>When a &lt;fieldset> is disabled, all descendant form controls are also disabled except for the form controls within the\u00a0&lt;legend>\u00a0element.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"example-of-the-html-span-class-attribute-disabled-span-attribute-used-on-the-lt-input-gt-element-9\">Example of the HTML&nbsp;disabled&nbsp;attribute used on the &lt;input&gt; element:<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;!DOCTYPE html&gt;\n&lt;html&gt;\n  &lt;head&gt;\n    &lt;title&gt;Title of the document&lt;\/title&gt;\n  &lt;\/head&gt;\n  &lt;body&gt;\n    &lt;form action=\"#\" method=\"get\"&gt;\n      &lt;input type=\"text\" name=\"name\" placeholder=\"Enter your name\" \/&gt;\n      &lt;input type=\"number\" name=\"Date of birth:\" placeholder=\"Date of birth:\" disabled\/&gt;\n      &lt;input type=\"submit\" value=\"Submit\" \/&gt;\n    &lt;\/form&gt;\n  &lt;\/body&gt;\n&lt;\/html&gt;<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"example-of-the-html-span-class-attribute-disabled-span-attribute-used-on-the-lt-optgroup-gt-element-11\">Example of the HTML&nbsp;disabled&nbsp;attribute used on the &lt;optgroup&gt; element:<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;!DOCTYPE html&gt;\n&lt;html&gt;\n  &lt;head&gt;\n    &lt;title&gt;Title of the document&lt;\/title&gt;\n  &lt;\/head&gt;\n  &lt;body&gt;\n    &lt;select&gt;\n      &lt;optgroup label=\"Books\" disabled&gt;\n        &lt;option value=\"html\"&gt;HTML&lt;\/option&gt;\n        &lt;option value=\"css\"&gt;CSS&lt;\/option&gt;\n      &lt;\/optgroup&gt;\n      &lt;optgroup label=\"Snippets\"&gt;\n        &lt;option value=\"java\"&gt;Java&lt;\/option&gt;\n        &lt;option value=\"linux\"&gt;Linux&lt;\/option&gt;\n        &lt;option value=\"git\"&gt;Git&lt;\/option&gt;\n      &lt;\/optgroup&gt;\n    &lt;\/select&gt;\n  &lt;\/body&gt;\n&lt;\/html&gt;<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"example-of-the-html-span-class-attribute-disabled-span-attribute-used-on-the-lt-option-gt-element-13\">Example of the HTML&nbsp;disabled&nbsp;attribute used on the &lt;option&gt; element:<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;!DOCTYPE html&gt;\n&lt;html&gt;\n  &lt;head&gt;\n    &lt;title&gt;Title of the document&lt;\/title&gt;\n  &lt;\/head&gt;\n  &lt;body&gt;\n    &lt;form&gt;\n      &lt;select&gt;\n        &lt;option value=\"computers\"&gt;Computer&lt;\/option&gt;\n        &lt;option value=\"notebook\"&gt;Notebook&lt;\/option&gt;\n        &lt;option value=\"tablet\" disabled&gt;Tablet&lt;\/option&gt;\n      &lt;\/select&gt;\n    &lt;\/form&gt;\n  &lt;\/body&gt;\n&lt;\/html&gt;<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Example of the HTML&nbsp;disabled&nbsp;attribute used on the &lt;select&gt; element:<\/h3>\n\n\n\n<h3 class=\"wp-block-heading\"><code>&lt;!DOCTYPE html> &lt;html> &lt;head> &lt;title>Title of the document&lt;\/title> &lt;\/head> &lt;body> &lt;form> &lt;select disabled> &lt;option value=\"books\">Books&lt;\/option> &lt;option value=\"html\">HTML&lt;\/option> &lt;option value=\"css\">CSS&lt;\/option> &lt;option value=\"php\">PHP&lt;\/option> &lt;option value=\"js\">JavaScript&lt;\/option> &lt;\/select> &lt;\/form> &lt;\/body> &lt;\/html><\/code><\/h3>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"example-of-the-html-span-class-attribute-disabled-span-attribute-used-on-the-lt-textarea-gt-element-17\">Example of the HTML&nbsp;disabled&nbsp;attribute used on the &lt;textarea&gt; element:<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;!DOCTYPE html&gt;\n&lt;html&gt;\n  &lt;head&gt;\n    &lt;title&gt;Title of the document&lt;\/title&gt;\n  &lt;\/head&gt;\n  &lt;body&gt;\n    &lt;form&gt; \n      &lt;textarea name=\"comment\" rows=\"8\" cols=\"50\" disabled&gt;Send your comments to the author.&lt;\/textarea&gt;\n    &lt;\/form&gt;\n  &lt;\/body&gt;\n&lt;\/html&gt;<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>The HTML&nbsp;disabled&nbsp;attribute is a boolean attribute and specifies that the element must be disabled. This attribute can be used to prevent using the element until some condition has been met, such as selecting a checkbox. When present, the element does not respond to user actions and cannot be focused. Then, it is possible to make [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[327],"tags":[],"_links":{"self":[{"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/posts\/9349"}],"collection":[{"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/comments?post=9349"}],"version-history":[{"count":0,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/posts\/9349\/revisions"}],"wp:attachment":[{"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/media?parent=9349"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/categories?post=9349"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/tags?post=9349"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}