-1

I have <div> like this:

<div style="display:none;" id="rd1"></div>
<div style="display:block;" id="rd2"></div>
<div style="display:block;" id="rd3"></div>
<div style="display:block;" id="rd4"></div>
<div style="display:none;" id="rd5"></div>
<div style="display:none;" id="rd6"></div>

I need to change style of those element which have a display:block style using only css code. I use this code but it's not W3 valid code.

div[style*='displayblock'] {
    background-colot:red;
}
smottt
  • 3,272
  • 11
  • 37
  • 44
Ritul Lakhtariya
  • 362
  • 1
  • 16
  • If you actually read what the validator told you, you'd realize that it has nothing to do with your selector. Even so, you have typos in both places anyway. But the real question is, what's the point of only selecting those with display:block in the first place? display:none will prevent the element from being rendered anyway. You're overcomplicating this. – BoltClock Jan 10 '15 at 07:10

1 Answers1

1

ref - A CSS selector to get last visible div

you can use this to div[style*="display:block"]

div[style*="display:block"]{
    background:red;
}
<div style="display:none;" id="rd1">fas</div>
<div style="display:block;" id="rd2">fsadf</div>
<div style="display:block;" id="rd3">fsdfa</div>
<div style="display:block;" id="rd4">faf</div>
<div style="display:none;" id="rd5">afsa</div>
<div style="display:none;" id="rd6">fa</div>
Community
  • 1
  • 1
Vitorino fernandes
  • 15,794
  • 3
  • 20
  • 39
  • It's not actually excluding anything because of the space between the colon and none in your attribute selector, but at the same time, it's completely utterly pointless to have an attribute selector in the first place for the reasons given in my comment above. You (the OP) should just remove the attribute selector altogether and just have `div`. – BoltClock Jan 10 '15 at 07:39
  • yes you are right @BoltClock – Vitorino fernandes Jan 10 '15 at 07:43
  • Yah i m sorry for that i m very new in html and all so its quite difficult to solve it, but thenks guys for support – Ritul Lakhtariya Jan 06 '17 at 10:26