5 Replies - 583 Views - Last Post: 23 July 2020 - 01:45 AM

#1 epoch+5   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 18
  • 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: 5552
  • View blog
  • Posts: 14,558
  • 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: 4278
  • View blog
  • Posts: 13,562
  • 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: 18
  • 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: 4278
  • View blog
  • Posts: 13,562
  • 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
  • +
  • -

#6 ishan.shah   User is offline

  • New D.I.C Head

Reputation: 3
  • View blog
  • Posts: 46
  • Joined: 28-March 19

Re: why is this selector not working?

Posted 23 July 2020 - 01:45 AM

Your can do that by simply applying property to that perticular class like
.header2
.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1