/* 비활성화된 textarea 스타일 */
textarea:disabled {
    color: #555;
    background-color: silver;
    border-color: #555;
    cursor: not-allowed; /* 입력하지 않도록 커서 변경 */
}
<fieldset>
    <legend>댓글 쓰기</legend>
    <textarea disabled>현재 댓글 쓰기는 닫혔습니다.</textarea>
</fieldset>
실제 적용된 모습
:disabled {
    /* ... */
}
[disabled] {
    border: 2px solid red; /* disabled 속성을 가진 모든 요소에 테두리 추가 */
}
:disabled {
    background-color: gold; /* 실제로 비활성화된 요소에 배경색 적용 */
}
<p disabled>disabled 속성이 있는 p 요소입니다.</p>
<input type="text" disabled> <!-- 실제로 비활성화된 입력 필드 -->
실제 적용된 모습
/* 잘못된 스타일링 - 비활성화된 요소가 화면에서 아예 보이지 않도록 스타일을 적용하는 것 */
:disabled {
    background-color: transparent;  /* 배경을 투명하게 설정 */
    color: transparent;  /* 글자 색을 투명하게 설정 */
}
<button disabled>비활성화된 버튼</button>
<form>
    <label for="search">검색어:</label>
    <input type="text" id="search" placeholder="검색어를 입력하세요">
    <button type="submit" id="search-button" disabled>검색</button>
</form>
[type="submit"]:disabled {
    color: #555;
    background-color: silver;
    border-color: silver;
    cursor: not-allowed; /* 클릭하지 않도록 커서 변경 */
}
const searchInput = document.getElementById("search");
const searchButton = document.getElementById("search-button");

searchInput.addEventListener("input", () => {
    // 검색어 입력이 있을 때 버튼 활성화
    if (searchInput.value.trim()) {
        searchButton.disabled = false; // 비활성화된 버튼을 활성화
    } else {
        searchButton.disabled = true; // 입력이 없으면 버튼 비활성화
    }
});
실제 적용된 모습