You are reading the article How To Disable The Elements And Style Disabled Elements? updated in September 2023 on the website Dacquyenphaidep.com. We hope that the information we have shared is helpful to you. If you find the content interesting and meaningful, please share it with your friends and continue to follow and support us for the latest updates. Suggested October 2023 How To Disable The Elements And Style Disabled Elements?
Introduction to CSS disabledWeb development, programming languages, Software testing & others
Real-Time Example: Suppose we fill a form with all our credentials like name, mobile number, Employee number, etc. Once we have entered all details, it will ask for confirmation to submit them. Once we submit, not all the details will allow for updating. The employee number is disabled to update because it is unique. Automatically it is disabled. In this kind of situation, we have used disabled selectors in CSS.
How Does disabled Done in CSS?As we discussed, disabled done on form pages in HTML. We can turn off the buttons, text fields, checkboxes, drop-down boxes, etc. by using the disabled selector on required HTML form elements.
Syntax:
input[type=text]:disabled { /*CSS declarations*/ } ExamplesBelow are the examples:
Example #1 – Field disabledCode:
h1 { color:orange; } input[type=text]:enabled { background: lightgray; } input[type=text]:disabled { background: red; font-size: 20px; } input { margin-top:10px; border:1px solid brown; font-size: 20px; } body { text-align:center; } p { color: brown; font-size: 22px; border: 2px ridge blue; } label { font-size: 20px; color: green; font-weight: bold; } Let suppose I am filling a form with all my credentials like my name, my mobile number, Employee number etc. Once I have entered all my details it will ask you for are sure confirm to submit the details. Once we submitted not all the details are going to allow for updating. Employee number is disabled to update because it is unique. Automatically is disabled. This kind of situation we have used disabled selector in CSS.
Output:
Explanation: As you can see in the output, you can edit the fields for First Name and Last Name, while the Address field is disabled and cannot be edited.
Example #2 – Disabled ButtonCode:
h1 { color:orange; } input[type=text]:enabled { background: lightblue; } input[type=text]:disabled { background: red; font-size: 20px; } input { margin-top:10px; border:1px solid pink; font-size: 20px; } body { text-align:center; } p { color: red; font-size: 22px; border: 2px ridge green; } label { font-size: 20px; color: blue; font-weight: bold; } button { color: purple; height: 30px; width: 150px; } Let suppose I am filling a form with all my credentials like my name, my mobile number, Employee number etc. Once I have entered all my details it will ask you for are sure confirm to submit the details. Once we submitted not all the details are going to allow for updating. Employee number is disabled to update because it is unique. Automatically is disabled. This kind of situation we have used disabled selector in CSS.
Output:
Explanation: As you can see in the output First Name and LastName can be editable, but the button is disabled, so we can’t edit it.
Example #3 – Text Area disabledh1 { color:red; } input[type=text]:enabled { background: lightgreen; } input[type=text]:disabled { background: red; font-size: 20px; } input { margin-top:10px; border:1px solid red; font-size: 20px; } body { text-align:center; } p { color: fuchsia; font-size: 22px; border: 2px ridge navy; } label { font-size: 20px; color: orange; font-weight: bold; } button { color: red; height: 30px; width: 150px; } Let suppose I am filling a form with all my credentials like my name, my mobile number, Employee number etc. Once I have entered all my details it will ask you for are sure confirm to submit the details. Once we submitted not all the details are going to allow for updating. Employee number is disabled to update because it is unique. Automatically is disabled. This kind of situation we have used disabled selector in CSS.
Output:
Explanation: As you can see, we can’t edit the text area as it is disabled.
ConclusionThe “disabled” selector in CSS is used to style and disable elements. We can use this disabled selector on form fields like buttons, text area, button, text field, etc.
Recommended ArticlesWe hope that this EDUCBA information on “CSS disabled” was beneficial to you. You can view EDUCBA’s recommended articles for more information.
You're reading How To Disable The Elements And Style Disabled Elements?
Update the detailed information about How To Disable The Elements And Style Disabled Elements? on the Dacquyenphaidep.com website. We hope the article's content will meet your needs, and we will regularly update the information to provide you with the fastest and most accurate information. Have a great day!