EDUCBA

EDUCBA

MENUMENU
  • Free Tutorials
  • Free Courses
  • Certification Courses
  • 600+ Courses All in One Bundle
  • Login

CSS disabled

By Priya PedamkarPriya Pedamkar

Home » Software Development » Software Development Tutorials » CSS Tutorial » CSS disabled

CSS disabled

Introduction to CSS disabled

The disabled is a selector in CSS, which is used to disabling the HTML elements. This disabled selector mostly works on form elements like text areas, buttons, checkboxes, drop-down boxes, etc.

Real Time Example: Let, suppose we are filling 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 the details. Once we submitted not all the details are going to 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.

Start Your Free Software Development Course

Web development, programming languages, Software testing & others

How Does disabled Done in CSS?

As we discussed disabled done on form pages in HTML. We can disable 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
}
<form action="">
Country: <input type="text" disabled="disabled" value="Pakistan">
</form>

Examples to Implement of CSS disabled

Below are the examples:

Example #1 – Field disabled

Code:

<!DOCTYPE html>
<html>
<head>
<title>disabled selector</title>
<style>
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;
}
</style>
</head>
<body>
<h1>Disabled Demo for Text Field</h1>
<p>
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.
</p>
<form action="">
<label>First Name :</label><input type="text" value="Paramesh"><br>
<label>Last Name: </label><input type="text" value="Nathi"><br>
<label>Address: </label><input type="text" disabled="disabled"
value="Phanigiri">
</form>
</body>
</html>

Output:

CSS Disabled Example 1

Explanation: As you can see in the output First Name and LastName can be editable but Address is disabled so we can edit it.

Example #2 – Disabled Button

Code:

<!DOCTYPE html>
<html>
<head>
<title>disabled selector</title>
<style>
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;
}
</style>
</head>
<body>
<h1>Disabled Demo for Button Field</h1>
<p>
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.
</p>
<form action="">
<label>First Name :</label><input type="text" value="Amardeep"><br>
<label>Last Name: </label><input type="text" value="Patel"><br>
<label>Country: </label><input type="text" value="India">
<br>
<br>
<button type="button" disabled>Edit Details</button>
</form>
</body>
lt;/html>

Output:

CSS Disabled Example 2

Explanation: As you can see in the output First Name and LastName can be editable but isbutton disabled so we can’t edit it.

Example #3 – Text Area disabled

Code:

<!DOCTYPE html>
<html>
<head>
<title>disabled selector</title>
<style>
h1 {
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;
}
</style>
</head>
<body>
<h1>Disabled Demo for Button Field</h1>
<p>
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.
</p>
<form action="">
<label>Name :</label><input type="text" value="Paramesh"><br>
<label>Email: </label><input type="text" value="naathi@gmail.com"><br>
<label>Country: </label><input type="text" value="India">
<br>
<br>
<label>comments:</label>
<textarea id="textArea" rows="4" cols="50" disabled>Hi, I am Paramesh. I am disabled.</textarea>
<br>
<br>
<button type="button">Edit Details</button>
</form>
</body>
</html>

Popular Course in this category
CSS Training (9 Courses, 9+ Projects)9 Online Courses | 9 Hands-on Projects | 61+ Hours | Verifiable Certificate of Completion | Lifetime Access
4.5 (5,444 ratings)
Course Price

View Course

Related Courses
Bootstrap Training (2 Courses, 6+ Projects)jQuery Training (8 Courses, 5 Projects)

Output:

Text Area Example 3

Explanation: As you can see we can’t edit text area as it is disabled.

Conclusion

Disabled in CSS is a selector which used to disable the elements and style disabled elements. We can use this disabled selector on form fields like buttons, text area, button, text field etc.

Recommended Articles

This is a guide to CSS disabled. Here we discuss a brief overview on CSS disabled and its different examples along with its code implementation. You can also go through our other suggested articles to learn more –

  1. CSS Resize
  2. Advantages of CSS
  3. CSS Interview Questions
  4. Button in CSS

CSS Training (9 Courses, 9+ Projects)

9 Online Courses

9 Hands-on Projects

61+ Hours

Verifiable Certificate of Completion

Lifetime Access

Learn More

0 Shares
Share
Tweet
Share
Primary Sidebar
CSS Tutorial
  • CSS
    • Introduction To CSS
    • What is CSS?
    • Uses Of CSS
    • Advantages of CSS
    • Career In CSS
    • CSS Commands
    • Is Css Case Sensitive
    • CSS object-fit
    • Types of CSS Selectors
    • CSS Radio Button
    • CSS Attribute Selector
    • CSS first child of class
    • CSS Selector nth Child
    • CSS Parent Selector
    • CSS Child Selector
    • CSS Not Selector
    • CSS Descendant Selector
    • CSS Inline Style
    • Checkbox CSS
    • CSS Appearance
    • CSS Font Properties
    • CSS font-variant
    • CSS Pagination
    • CSS Table Styling
    • CSS Table Cell Padding
    • CSS Padding Color
    • CSS Text Formatting
    • CSS for Text-Shadow
    • CSS text-stroke
    • CSS text-indent
    • CSS Rotate Text
    • CSS Text Color
    • CSS Center Div
    • CSS Arrow
    • CSS Arrow Down
    • CSS offset
    • CSS Cursor
    • CSS Layout
    • CSS Grid Layout
    • Button in CSS
    • CSS Button Border
    • text-align in CSS
    • CSS Horizontal Align
    • CSS Position
    • CSS Box Sizing
    • CSS box-shadow
    • CSS Text Underline
    • CSS Text Outline
    • CSS Blinking Text
    • Text Decoration CSS
    • CSS Vertical Align
    • CSS Word Wrap
    • CSS Padding
    • CSS Font Color
    • CSS Color Generator
    • CSS Margin Right
    • CSS Margin Color
    • CSS Color Codes
    • CSS Color Transparent
    • CSS Color Chart
    • CSS Link Color
    • CSS z-index
    • CSS Curved Border
    • CSS Border Left
    • CSS left
    • CSS Gradient Generator
    • Radial Gradient in CSS
    • CSS Shape Generator
    • CSS Triangle Generator
    • CSS background-color
    • CSS Background Image
    • CSS background-clip
    • CSS background-blend-mode
    • CSS Drop Shadow
    • CSS line height
    • CSS line break
    • Sticky Footer CSS
    • CSS Header Design
    • CSS Border Style
    • CSS Border Generator
    • Sticky Sidebar CSS
    • CSS Transparent Border
    • CSS Border Radius
    • CSS translate
    • CSS transform
    • CSS 3D Transforms
    • CSS Text Transform
    • CSS Transition Effects
    • CSS Transition Property
    • CSS Animation Transition
    • Negative Margin CSS
    • CSS Navigation Bar
    • CSS Overflow
    • CSS overflow-wrap
    • CSS Lists
    • CSS list-style
    • CSS Order
    • CSS Box Model
    • CSS Inner Border
    • CSS Icon
    • Menu Icon CSS
    • CSS Multiple Borders
    • Opacity in CSS
    • CSS Float Right
    • CSS Clear Float
    • CSS clip
    • CSS disabled
    • CSS Border Padding
    • Border Images in CSS
    • CSS Visibility
    • CSS Validator
    • CSS Clearfix
    • CSS Counter
    • CSS Letter Spacing
    • CSS root
    • CSS zoom
    • CSS calc()
    • CSS.supports()
    • CSS Loader
    • Media Query CSS
    • CSS @keyframes
    • CSS @bottom
    • CSS page-break-after Property
    • CSS page-break
    • CSS Position Fixed
    • CSS skew()
    • CSS Row
    • CSS Masking
    • CSS Scrollbar
    • CSS Overlay
    • CSS Important
    • CSS Cursor Hand
    • CSS Inherit
    • CSS Position Relative
    • CSS Compressor
    • CSS tricks
    • CSS Outline Property
    • CSS Flexbox Properties
    • CSS flex-direction
    • CSS content property
    • CSS Typography
    • CSS Formatter
    • CSS nowrap
    • CSS Column
    • GridView CSS
    • CSS Viewport
    • CSS Minify
    • CSS Combinators
    • CSS in React
    • CSS Matrix 
    • CSS Pseudo Elements
    • CSS Pseudo Classes
    • CSS Pointer Events
    • CSS Resize
    • CSS Inheritance
    • CSS Interview Questions
    • Cheat Sheet CSS
  • CSS3
    • What is CSS3?
    • CSS3 Interview Questions
    • Cheat sheet CSS3
  • sass
    • How to Install SASS
    • SASS Interview Questions
    • What is Sass
    • SASS Comments
    • Sass Variables
    • SASS Import
    • SASS if else
    • SASS Nesting
    • SASS @each
    • SASS @at-root
    • SASS @extend
    • SASS @media
    • SASS @for
    • SASS Map
    • SASS Selectors
    • SASS Color Functions
    • SASS Mixins

Related Courses

CSS Training Course

Bootstrap Training Course

JQuery Training Course

Footer
About Us
  • Blog
  • Who is EDUCBA?
  • Sign Up
  • Corporate Training
  • Certificate from Top Institutions
  • Contact Us
  • Verifiable Certificate
  • Reviews
  • Terms and Conditions
  • Privacy Policy
  •  
Apps
  • iPhone & iPad
  • Android
Resources
  • Free Courses
  • Java Tutorials
  • Python Tutorials
  • All Tutorials
Certification Courses
  • All Courses
  • Software Development Course - All in One Bundle
  • Become a Python Developer
  • Java Course
  • Become a Selenium Automation Tester
  • Become an IoT Developer
  • ASP.NET Course
  • VB.NET Course
  • PHP Course

© 2020 - EDUCBA. ALL RIGHTS RESERVED. THE CERTIFICATION NAMES ARE THE TRADEMARKS OF THEIR RESPECTIVE OWNERS.

EDUCBA Login

Forgot Password?

EDUCBA
Free Software Development Course

Web development, programming languages, Software testing & others

*Please provide your correct email id. Login details for this Free course will be emailed to you
Book Your One Instructor : One Learner Free Class

Let’s Get Started

This website or its third-party tools use cookies, which are necessary to its functioning and required to achieve the purposes illustrated in the cookie policy. By closing this banner, scrolling this page, clicking a link or continuing to browse otherwise, you agree to our Privacy Policy

EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA
Free Software Development Course

Web development, programming languages, Software testing & others

*Please provide your correct email id. Login details for this Free course will be emailed to you

Special Offer - CSS Training (9 Courses, 9+ Projects) Learn More