OR in CSS selector

You can use a CSS selector, such as a[href^="http:"], a[href^="mailto:"]to match all external and mail links within the document, but is there a way to use the "or" operator in the selector quotation mark section, for example:a[href^="(http|mailto):"]

+5
source share
2 answers

As far as I can tell, there is no way to do what you ask. In the CSS selector specification, the channel symbol is used for something else when used with attribute selectors. It is used as a namespace delimiter.

In the selector specification on the W3C:

CSS : , , " " (|). XML, , , ( "| attr"; , , "). .

CSS examples:

@namespace foo "http://www.example.com";
[foo|att=val] { color: blue }
[*|att] { color: yellow }
[|att] { color: green }
[att] { color: green }

att "http://www.example.com" "val".

att ( ).

att, .

: http://www.w3.org/TR/selectors/#attrnmsp

+5

CSS Selectors, , , - :

selectors_group
  : selector [ COMMA S* selector ]*

, :

{w}"+"           return PLUS;
{w}">"           return GREATER;
{w}","           return COMMA;
{w}"~"           return TILDE;

, , :

"{N}{O}{T}"("  return NOT;)

http://www.w3.org/TR/selectors/#w3cselgrammar

0
source

All Articles