JavaFX CSS significantly differs from W3C CSS (Forked from RE: Proposal to move default style-class from Control to SkinBase)

Tom Schindl tom.schindl at
Thu Aug 8 01:22:35 PDT 2013

Hi Pedro,

on CSS as a spec: You are right the spec does not only hold a language
                  definition but also the definition of e.g. the
                  box-model, ... who simply can not be applied to FX
                  unless you completely revamp how it works

on CSS: The grammer of the CSS-Language is at with a descrption at with updates in later
        specs and CSS can not only be applied to HTML-Doms but e.g.
        also to SVG where you have completely different attributes.

        See how few
        properties SVG and HTML-CSS share! So to me it looks like the
        authors of SVG see CSS in the same way the JavaFX-Team does it
        as a styleing DSL leaving out things like the Box-Model, ...

on SASS: I see no reason it can not be used. Like I said SASS is simply
         syntatic sugar above the CSS Language, but it does not really
         care about how the properties are named! I've attached you a
         sample of scss file derived from the projects website using
         JavaFX properties and to me the output looks correct, maybe
         there are advanced features I'm not aware of - I haven't used
         SASS at all

on Compass: This one does not work with FX because it somehow deals
            with the properties

on reusing CSS-HTML-Properties: I think the confusion would be getting
          worse if we'd start mixing HTML-CSS-Property names with -fx
          ones (which we need in any case) - even if we can get them
          100% HTML-CSS compliant.

          I don't see me blindly copying a HTML-CSS which assumes the
          Box-Model, element-types who are not existing in FX at all


On 08.08.13 02:58, Pedro Duque Vieira wrote:
> Go to the CSS W3C website and read the spec, you'll see that it's not
> only a language. 
> No SASS can't be used with JavaFX unless you make a SASS of your own
> that works like the original but with JavaFX CSS files.
> Thanks, regards,
> On Thu, Aug 8, 2013 at 1:38 AM, Tom Schindl <tom.schindl at
> <mailto:tom.schindl at>> wrote:
>     SASS can be used as well in fx, it is simply a preprocessor, like
>     LESS, and for CSS the language and selectors there is a grammer! 
>     CSS is simply a DSL and its most important part are the selectors
>     and its cascading nature.
>     Tom
>     Von meinem iPhone gesendet
>     Am 08.08.2013 um 02:11 schrieb Pedro Duque Vieira
>     <pedro.duquevieira at <mailto:pedro.duquevieira at>>:
>>     I might have jumped the gun when talking about LESS, I'm not
>>     actually familiar with it and thought it would be along the same
>>     lines like SASS.
>>     But still you can't use SASS or Compass with JavaFX CSS.
>>     Cheers,
>>     On Thu, Aug 8, 2013 at 1:05 AM, Pedro Duque Vieira
>>     <pedro.duquevieira at <mailto:pedro.duquevieira at>>
>>     wrote:
>>             > So if you invent the same node-types you have on the web (lets face it there's only a handful of them most important are most likely div,span) and give them the same properties you know from the web you can copy your Web-CSS stylesheet to your FX-Application.
>>             +1 to this idea (in a 3rd party lib).
>>             > The issue I see is that JavaFX CSS significantly differs from W3C CSS
>>             It surprises me that this issue comes up so rarely in
>>             JavaFX forums (almost never) - perhaps it is because
>>             JavaFX developers tend to be Java developers rather than
>>             designers.
>>             A related open jira request
>>             is "need to
>>             reconcile JavaFX CSS with W3C CSS3" 0 votes (no interest
>>             at all?).
>>             In terms of conversion of existing html css resources to
>>             javafx css, you may be interested in a Q&A with a
>>             developer who converted the Foundation look and feel to
>>             JavaFX ( - from
>>             his point of view the conversion process was quite
>>             straight-forward - though perhaps that was partially luck
>>             of the draw.
>>             Below is a copy and paste from an earlier JavaFX forum
>>             post on this topic:
>>             You know, sometimes I find JavaFX's lack of certain css
>>             features refreshing. It is nice to have all, well, almost
>>             all, of the JavaFX CSS documented on one page. I think if
>>             you were to do the same thing for w3c css then it would
>>             end up with a much larger, more difficult to understand
>>             document and even what the contents of that document
>>             should be would probably be pretty controversial, in the
>>             same kind of way that the HTML5 specification ended up
>>             being. Microsoft contributed over 7000 tests to w3c just
>>             to cover only a subset of the css rules available in
>>             browsers today. The webkit project lists almost a thousand
>>             open CSS
>>             bugs:
>>             So implementing even partial w3c CSS support is a complex
>>             project.
>>             When I first started using JavaFX CSS I found the
>>             differences to w3c CSS quite jarring, and it was hard to
>>             account for them. Now that I am used to JavaFX CSS, I
>>             don't have as much of an issue. The difference in names
>>             and semantics is going to be an impediment to designers
>>             working on JavaFX who are familar with w3c CSS - but the
>>             designers will quickly also discover that FXML is not HTML
>>             and Java is not JavaScript and JavaFX deployment is not
>>             HTML deployment. So, perhaps, in the larger picture, it is
>>             not as big a deal as it would seem. Still, one can't help
>>             think that any impediment to people easily picking up and
>>             adopting JavaFX is doing the technology a disservice.
>>             There are other advantages in having the JavaFX CSS in its
>>             own namespace to w3c css, in that it can evolve
>>             seperately, it is not expected to be exactly the same
>>             because it has a different name, it is not expected to
>>             fully implement w3c css as browsers do because it's
>>             clearly a different thing by name, etc. There is even
>>             precedent for it in the use by mozilla of moz- CSS
>>             prefixes and webkit css
>>             properties - the
>>             web as not as standard as a lot of people propose. JavaFX
>>             CSS is backing a JavaFX rendering engine and not an HTML
>>             rendering engine. It is quite remarkable that Oracle was
>>             able to build and make available a CSS model for JavaFX
>>             that feels as familiar as it does to w3c css, as w3c css
>>             is targeted very strongly toward styling a completely
>>             different technology set (HTML markup and document object
>>             model).
>>             It would be useful to have a tool which translates w3c css
>>             to approximations of JavaFX css and vice versa, or the
>>             ability for JavaFX to have a mode (perhaps a boolean value
>>             when a stylesheet is loaded) to perform an automatic alias
>>             or mapping of w3c css to javafx (at least for the subset
>>             of w3c css which would make sense to automatically
>>             translate to JavaFX css).   (David commented on this part
>>             previously - "Closing the gap between JavaFX CSS and W3C
>>             CSS will be an evolutionary process. It would be nice to
>>             use a standard's based stylesheet but there is not always
>>             a 1-1 mapping to JavaFX. But for those properties that can
>>             be mapped, it is something that should be supported. For
>>             example, we should be able to handle "font" or "-fx-font".")
>>             Comments above relate to the naming and semantic meanings
>>             of css tags, and not the syntax and parsing of css (as
>>             both w3c css and javaFX css seem to be equivalent in the
>>             later regard).
>>             The JavaFX css model is really powerful and I have found
>>             really useful some of the additions that it adds above the
>>             baseline 2.1 css that is found consistently in browsers.
>>             With the upcoming Java CSS object
>>             model "CSS
>>             Style Object Model in Java" 23 votes, you will also get
>>             better programmatic access from Java, which seems to be a
>>             highly requested feature.
>>             Regards,
>>             John
>>         Hi John,
>>         Thanks for your input. That's exactly my view on things. 
>>         I'm also surprised so few people ever talk about this, not
>>         wanting to hurt anybody's feelings, I guess the vast majority
>>         probably don't do web development or are not really acquainted
>>         with CSS and its intricacies, but that's just a guess.
>>         Also one more advantage I see if JavaFX complies with w3c CSS
>>         (on the things that count) is that CSS is a continuously
>>         evolving technology with a lot of people already working on it
>>         and evolving it (for instance, the broken layout system is
>>         being rewritten with things like the box model), if JavaFX
>>         follows along it will benefit from that web of knowledge.
>>         @Tom Schindl: I'm not talking about only the "CSS language",
>>         there is no such thing (I guess its also a bit controversial
>>         to call "JavaFX CSS", "CSS" at all). W3C CSS is much more than
>>         a "language", what good would CSS be if you hand't got
>>         keywords, like "font", "color", "margin", etc. 
>>         You also don't have to invent all the nodes "div", etc, to rip
>>         the benefits of having a more compliant W3C CSS. These can
>>         come later.
>>         One of the problems is that JavaFX adds a "-fx-" prefix to
>>         every keyword, the use of this prefix was meant to distinguish
>>         experimental browser new specific features during their
>>         testing, experimentation period. This was during an
>>         experimental phase, and was meant to be dropped as soon as all
>>         browser implementations of that new feature work the same.
>>         In JavaFX by contrast, this was added for the purposes of
>>         being able to write in the same stylesheet file both web w3c
>>         css and JavaFX css without the 2 clashing into each other. But
>>         I don't agree with this, and I think it's such a minor use
>>         case that the disadvantages clearly outweigh the advantages.
>>         For this use case why not have 2 separate stylesheets, what's
>>         the issue of separating things into 2 distinct files and also
>>         I think that it's much simpler to read and maintain 2
>>         different stylesheets that cram everything into 1.
>>         But all this can be changed, we can have both -fx- prefixed
>>         properties and non -fx- prefixed properties and with this not
>>         breaking backwards compatibility.   
>>         Thanks, regards,
>>         -- 
>>         Pedro Duque Vieira 
>>     -- 
>>     Pedro Duque Vieira
> -- 
> Pedro Duque Vieira

-------------- next part --------------
.button {
  -fx-font: {
    family: serif;
    weight: bold;
    size: 1.2em;

.error {
  -fx-border-width: 1px;
  -fx-border-color: #fdd;
  -fx-background-color: #fdd;
.error.intrusion {
  -fx-font-size: 1.3em;
  -fx-font-weight: bold;

.badError {
  @extend .error;
  -fx-border-width: 3px;

More information about the openjfx-dev mailing list