[Mapcss] Selector syntax

Sebastian Klein bastikln at googlemail.com
Sat Mar 12 20:03:46 GMT 2011

Thomas Davie wrote:
> The mapCSS 0.2 wiki page states that we may not write
> relation[type=route]
>  way[highway]
>   { stroke-color: red; }
> as
> relation [type=route]
>   way [highway]
>    { stroke-color: red; }
> I see no reason why allowing this would make the grammar ambiguous, and 
> disallowing it makes the grammar significantly more complex (we can't 
> simply ignore whitespace tokens any more, and have to pollute every 
> grammar rule with whitspace? between pretty much all tokens).
> What's the reason for this restriction?

The reason for this is to comply with css. Try the following snippet:

  <style type="text/css">

    p [lang=en] { color: purple; }


  <p lang="en">normal text</p>

  <p>text <span lang="en">in purple</span></p>

The browser will consider [lang=en] to be a shortcut for *[lang=en] and make everything purple that has the lang=en property and is descendent of a <p> element.


More information about the Mapcss mailing list