CSS - Pseudo-class :disabled



The CSS pseudo-class selector :disabled represents an element that is disabled. An element is in disabled stated, if it can not be activated (selected, clicked on, typed into, etc) or doesn't accept focus.

Syntax

:disabled {
   /* ... */
}

CSS:disabled Example

Here is an example of :disabled pseudo-class. Here you see a disabled input and button.

<html>
<head>
<style>
	input[type=text]:enabled {
		background: white;
	}

	input[type=text]:disabled {
		background: lightgrey;
	}

	input {
		width: 150px;
		padding-left: 10px;
		margin-top: 10px;
		border: 1px solid black;
	}
</style>
</head>
<body>
	<h2>:disabled example</h2>
	<form action="">
      <label>Doctor Name</label>
      <input type="text"><br>
      <label>Hospital Name</label>
      <input type="text"><br>
      <label>Diagnosis</label>
      <input type="text" disabled="disabled" value="Diagnosis"><br><br>
      <button type="submit" disabled="disabled">Submit</button>
      <button type="reset">Reset</button>
	</form>
</body>
</html>
Advertisements