-4

So we suppose we want to create and HTML site and we want to use the below CSS Selectors:

.error but our browser does not support- class selector (.error)

#footer but our browser does not support- id selector (#footer)

a:link but our browser does not support -pseudo-class :link

[lang|="en"] but our browser does not support- [attr|=value] and also pseudo-class :lang()

:not(:first-child) but our browser does not support pseudo-class :not()

img:not(:first-of-type) but our browser does not support pseudo-class :not()

*li:nth-child(-n+3)*but our browser does not support pseudo-class :nth-child()

Does anybody know how we can write the above selectors without the ones that our browser does not support? Only think i have found so far is that we can use [class~="error"] instead of .error.

  • I dont use any browser . The X browser is hypothetical. Probably all the browsers support the above i just want an answer out of curiosity. – Aggelos Sfakianos Apr 07 '16 at 11:11
  • 1
    You mentioned 'the above CSS selectors', but I'm not seeing any and the title doesn't mention any as well. Which browser is giving you this error? And have you tried running it on different browsers? – Ahmed Aboumalek Apr 07 '16 at 11:12
  • 1
    @Angelo I guess (s)he just meant "below" – Djizeus Apr 07 '16 at 11:15
  • 1
    Some of you examples [are level 1 selectors](https://www.w3.org/TR/selectors/#selectors) which are supported by all browsers. – Vucko Apr 07 '16 at 11:15
  • I said already i know all browsers support most of the above. My question is how to write them/apply them with different syntax if we **SUPPOSE** that an **hypothetical browser** does not support the above selectors on the right side. – Aggelos Sfakianos Apr 07 '16 at 11:19
  • What's the point of that "hypothetical browser" if it doesn't support the simplest selectors? – Vucko Apr 07 '16 at 11:20
  • What's the context here? What problem are you having, exactly? – Shaggy Apr 07 '16 at 11:21
  • I never said i have a problem i have a a question that needs an answer. To put it simply. I want to use a CSS Selector(any css selector doesn't matter) but i want to use it witout a specific pseudo-class or the selector itself( by using html code i guess) is there a way to do that? And if yes what way? – Aggelos Sfakianos Apr 07 '16 at 11:27
  • _"by using html code i guess"_ - you can use the `style` attribute => `

    foobar

    ` ?
    – Vucko Apr 07 '16 at 11:34

1 Answers1

1

All the recent browsers support all the possible CSS selectors including Attribute selectors. Compatibilty list:

However, to feed your curiosity, it's possible to link a stylesheet to a specific browser. Only, it's not that easy, you'll have to apply it with Javascript. I invite you to read the following topic regarding this matter:

Community
  • 1
  • 1
Ahmed Aboumalek
  • 613
  • 4
  • 21