domenic / html-as-custom-elements

HTML as Custom Elements
https://domenic.github.io/html-as-custom-elements/
Apache License 2.0
260 stars 20 forks source link

Missing presentational attributes #27

Open abarth opened 10 years ago

abarth commented 10 years ago

Many HTML elements have presentation attributes, which get translated into CSS properties that get inserted into a particular place in the cascade:

"The UA may choose to honor presentational attributes in an HTML source document. If so, these attributes are translated to the corresponding CSS rules with specificity equal to 0, and are treated as if they were inserted at the start of the author style sheet. They may therefore be overridden by subsequent style sheet rules."

http://www.w3.org/TR/CSS2/cascade.html

I don't know of any way currently for a web component to insert presentational CSS into the correct place in the cascade.

dglazkov commented 10 years ago

@tabatkins for moar insight.

domenic commented 10 years ago

I might be way off-base, but this seems tenuously connected to the proposal to allow authors to set their own initial styles. It sounds like what we're talking about here aren't actually initial styles proper, but they seem to serve similar use cases for authors.

One way of looking at this connection might be, if we provide some way for authors to set these "specificity 0 default styles," we have also solved some of the use cases in that thread (although not the transition-timing-function one, I think).

tabatkins commented 10 years ago

Elliot and I have discussed, in the context of constructable Stylesheet objects, being able to set up "default" sheets that apply at the specificity discussed here. There's a bunch of interesting concept-space lying here that we should explore.

domenic commented 10 years ago

That sounds really nice. "Constructable Stylesheet objects" sounds much like the underpinnings of <custom-style>, too.

I imagine then we could add a declarative version, <style default> or something, once the imperative API is figured out.

tabatkins commented 10 years ago

Specifically:

  1. Being able to set styles at "default" level, below all non-default styles in the cascade. (Just using * as the selector almost does this; the only difference is that this is below * selector rules.)
  2. Being able to set styles at "initial" level, below even the default styles, that fill in values unspecified in shorthands too. (This might subsume the previous one. Need use-cases to tell.)
  3. Being able to create stylesheets that apply in all components at some default level. You can't use * /deep/ * for this, because outer rules win over all inner rules when dealing with cross-shadow contexts. (Most of the time this is what you want, as you're usually tweaking existing component styles with that kind of style.)