4 Replies - 325 Views - Last Post: 23 June 2020 - 01:43 AM

#1 epoch+5   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 27-April 20

why is this selector not working?

Posted 19 June 2020 - 02:26 PM

in my html i have

<h2 class="header2">This is an h2 for me</h2>


in my CSS i have

h2 [class|=header2] {
    background: red;
}


why is it not styling?
Is This A Good Question/Topic? 0
  • +

Replies To: why is this selector not working?

#2 Martyr2   User is offline

  • Programming Theoretician
  • member icon

Reputation: 5549
  • View blog
  • Posts: 14,557
  • Joined: 18-April 07

Re: why is this selector not working?

Posted 19 June 2020 - 03:19 PM

Try no space between the h2 and the [.

h2[class|=header2] {
    background: red;
}


Was This Post Helpful? 0
  • +
  • -

#3 Dormilich   User is offline

  • 痛覚残留
  • member icon

Reputation: 4277
  • View blog
  • Posts: 13,545
  • Joined: 08-June 10

Re: why is this selector not working?

Posted 19 June 2020 - 05:46 PM

wouldn't be h2.header2 much more straightforward?
Was This Post Helpful? 1
  • +
  • -

#4 epoch+5   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 27-April 20

Re: why is this selector not working?

Posted 22 June 2020 - 01:43 PM

Dormlich what would the difference be?
Was This Post Helpful? 0
  • +
  • -

#5 Dormilich   User is offline

  • 痛覚残留
  • member icon

Reputation: 4277
  • View blog
  • Posts: 13,545
  • Joined: 08-June 10

Re: why is this selector not working?

Posted 23 June 2020 - 01:43 AM

you know what the |= selector does? Given the posted HML code, using the plain class selector seems sufficient.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1