Stylized style for div element.

I am trying to style the disabled state for a div. I have code

<div disabled> Welcome </div>
<style>
    div:disabled{
      background-color:#f1f1f1;
    }
</style>

I do not have a class or identifier present in the element. It is generated by the system. I want to make the background color light gray.

+4
source share
4 answers

Try using the attribute selector:

div[disabled]{}

See additional information:

https://www.w3schools.com/css/css_attribute_selectors.asp

+3
source

This can be achieved using attribute selectors, in this case, "disabled" - this attribute:

div[disabled] {
    background-color: #f1f1f1;
}

, MDN

, .

+2

In a div, disabledis an attribute. Therefore, use the attribute selector.

<div disabled> Welcome </div>
<style>
      div[disabled] {
         background-color:#f1f1f1;
      }
</style>

https://developer.mozilla.org/en-US/docs/Web/CSS/Attribute_selectors

+1
source

css for attribute

div[disabled]{
     background-color:#f1f1f1;
  }
0
source

Source: https://habr.com/ru/post/1676829/


All Articles