How to style CSS role

Use CSS attribute selectors:

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

e.g.:

div[role=main]

Accessing it like this should work: #content[role="main"]


The shortest way to write a selector that accesses that specific div is to simply use

[role=main] {
  /* CSS goes here */
}

The previous answers are not wrong, but they rely on you using either a div or using the specific id. With this selector, you'll be able to have all kinds of crazy markup and it would still work and you avoid problems with specificity.

[role=main] {
  background: rgba(48, 96, 144, 0.2);
}
div,
span {
  padding: 5px;
  margin: 5px;
  display: inline-block;
}
<div id="content" role="main">
  <span role="main">Hello</span>
</div>

Sure you can do in this mode:

 #content[role="main"]{
       //style
    }

http://www.w3.org/TR/selectors/#attribute-selectors


we can use

 element[role="ourRole"] {
    requried style !important; /*for overriding the old css styles */
    }