Meeseeks.CSS (Meeseeks v0.17.0) View Source

Compile CSS selector syntax into Meeseeks.Selectors.

Supported Syntax

PatternExampleNotes
Basic Selectors------
**Matches any for ns or tag
tagdiv
ns|tagfoo|div
#iddiv#bar, #bar
.classdiv.baz, .baz
[attr]a[href], [lang]
[^attrPrefix]div[^data-]
[attr=val]a[rel="nofollow"]
[attr~=valIncludes]div[things~=thing1]
[attr|=valDash]p[lang|=en]
[attr^=valPrefix]a[href^=https:]
[attr$=valSuffix]img[src$=".png"]
[attr*=valContaining]a[href*=admin]
​
Pseudo Classes------
:first-childli:first-child
:first-of-typeli:first-of-type
:last-childtr:last-child
:last-of-typetr:last-of-type
:notnot(p:nth-child(even))Selectors cannot contain combinators or the not pseudo class
:nth-child(n)p:nth-child(even)Supports even, odd, 1.., or an+b formulas
:nth-last-child(n)p:nth-last-child(2)Supports even, odd, 1.., or an+b formulas
:nth-last-of-type(n)p:nth-last-of-type(2n+1)Supports even, odd, 1.., or an+b formulas
:nth-of-type(n)p:nth-of-type(1)Supports even, odd, 1.., or an+b formulas
​
Combinators------
X Ydiv.header .logoY descendant of X
X > Yol > liY child of X
X + Ydiv + pY is sibling directly after X
X ~ Ydiv ~ pY is any sibling after X
X, Y, Zbutton.standard, button.alertMatches X, Y, or Z

Examples

iex> import Meeseeks.CSS
iex> css("a[href^=\"https://\"]")
%Meeseeks.Selector.Element{
  combinator: nil,
  selectors: [
    %Meeseeks.Selector.Element.Tag{value: "a"},
    %Meeseeks.Selector.Element.Attribute.ValuePrefix{
      attribute: "href",
      value: "https://"}]}
iex> css("ul, ol")
[%Meeseeks.Selector.Element{
    combinator: nil,
    selectors: [%Meeseeks.Selector.Element.Tag{value: "ul"}]},
 %Meeseeks.Selector.Element{
   combinator: nil,
   selectors: [%Meeseeks.Selector.Element.Tag{value: "ol"}]}]

Link to this section Summary

Functions

Compiles a string representing CSS selector syntax into one or more Meeseeks.Selectors.

Link to this section Functions

Link to this macro

css(string_literal)

View Source (macro)

Compiles a string representing CSS selector syntax into one or more Meeseeks.Selectors.

When a static string literal is provided this work will be done during compilation, but if a string with interpolated values or a var is provided this work will occur at run time.