Selector API - Logical Operator

> (World Wide) Web - (W3|WWW) > Selector API

1 - About

Logical operator in the selector API.

Predicates can be:

  • intersected (“.a.b”)
  • or unioned (“.a, .b”)

3 - List

3.1 - Or (Unioned)

An union or an or is accomplished be separating the selector by a comma.

Example: .a, .b

#IdName, .className  { color:blue; }
  • The HTML
<div id="IdName">The blue color CSS style will be applied on this text</div>
<div class="className">and one this one</div>
  • The result:

Advertising

3.2 - And (intersection)

3.2.1 - Id and class

#IdName.className  { color:blue; }
  • The HTML
<div id="IdName" class="className">The CSS style will be applied on this text</div>
<div>Not on this one</div>
  • The result:

3.2.2 - Element and class

  • An element selector and a class selector (ie selects element “div” with the class “className”)
div.className  { color:blue; }
  • The HTML
<div class="className">The CSS style will be applied on this text because it's a div element with the class className</div>
<div>Not on this one because it has no class</div>
  • The result:

Advertising
web/selector/logical_operator.txt · Last modified: 2019/02/09 11:43 by gerardnico