Re: inheritance from nonancestor

Approximate CCs already sent: "Henrik Andersson" <henke@henke37.cjb.net>, greg.davis@pearson.com, "Richard Gibson" <richard.gibson@gmail.com>, "Tab Atkins Jr." <jackalmage@gmail.com>

Hopefully, this way everyone gets my answers, but I can (re)send separate replies if needed.

> A big problem is loops. Inheritance is loop free.

That hints at something beyond my expertise. I'd think there'd be a way to call a style from a user agent regardless of ancestry and load it into an overriding temporary stylesheet, but that's just my imagination.

> As for your particular problem, have you considered using more than one selector? One that matches both elements and one that only matches one of them.

I'm probably missing something, but that sounds like I'd still have to know how a browser styles by default and brands and versions vary. If I write my own style in entirety, I think I'd then have the problem of design coordination with other styles, solvable only by specifying every style I use so no browser defaults come into use, and that's too much work, especially since I'd have to add accessibility styles and users' own prefs.

> One option to fix your problem here would be to use sectioning tags like <article>, <aside>, <nav> and <section> and then use <header> to contain the <h1> and subtitle elements. The pattern we use in book production, and one that is sanctioned by the IDPF for EDUPUB content is:
> <section>
>     <header>
>         <h1>Title</h1>
>         <p class="subtitle">Subtitle</p>
>     </header>
>     ...
> </section>
> Of course, if the <h1> is the title to your whole page, <header> can also act as a child of <body> for the same purpose, and then each cascading <section> get's <h2>, <h3>, etc.
> The other benefit of <header> is that it can contain all kinds of things that are "header" material. Search elements, logos, etc... are all game for inclusion.
That pattern requires styling p and that seems to require knowing how browsers style h[n] and p so that my p would be almost like h1 but not too much like p. I do a lot of my work on my laptop, which doesn't have costly IE or Edge and won't.

I do use the article etc. tags. I don't remember if a header can be a child of a section or if more than one header element is allowed on a page, but my design is, roughly, a header and a footer for the full width and, at least for desktops, three columns across between the header and the footer, with the middle column being for the main text (my search box is in the right column). I'm not sure that adding a second header, especially with h1, into the center column isn't going to confuse search engines.

> This case is also explicitly covered in the HTML Living Standard:
>     <hgroup>
>      <h1>Dr. Strangelove</h1>
>      <h2>Or: How I Learned to Stop Worrying and Love the Bomb</h2>
>     </hgroup>

Thank you for pointing me to that standard. I've been using W3C's HTML5. I may have seen this one before but thought it was something like a working draft; now I see it may not be, but I need to depend on what user agents including bots are likely to expect. It seems that Apple, Firefox, and Opera likely use WHATWG's but probably Google uses W3C's (a W3C editor is from Google) and I'd have to guess which one Microsoft uses. So that makes using hgroup unlikely unless I write in alternative coding for user agents that ignore hgrop because they don't understand it, and that may be more trouble than it's worth. I'll likely look into this standards split soon.

> In general, things like this can be addressed with Custom Properties and variables.
> * * * * *

I wasn't aware of https://www.w3.org/TR/css-variables/ and the code sample you provided looks interesting. I plan to read up on it shortly. At least, it looks like a time-saver for other purposes (I have 20 at-media rules with much similarity). Hopefully, it doesn't require that I define all characteristics of a style or know what a browser will do.

> I could have sworn that they pulled the hgroup element. I guess they unpulled it?

And:

> Pulled from W3C, but not WHATWG . . .

A discrepancy of a whole element is a problem, per the above.

(Blank lines omitted from quotations. Quotes may differ in CCs above and are accurate there. )

For now, I'll rely on my span hack (even though adding microdata requires about three more spans) but Custom Properties looks promising. And, if other authors have a similar need, I hope the loops problem can be solved or gotten around.

Thank you for all this.

-- 
Nick

Received on Monday, 7 March 2016 12:50:01 UTC