Re: inheritance from nonancestor

Nick Levinson skrev:
> It would help if we could inherit nonancestral style. This would improve consistency across browsers. To that end, we apparently need an addition to the CSS specs. Test case: For the sake of a search engine, only one h1 element should appear on a page, but I want a subtitle with a slightly smaller font-size. So writing two h1 elements, even with different classes or id values, is out. And writing the subtitle as h2 immediately after the h1 is also out. Both are forbidden by HTML5, section 4.12.1. But if I write and style a p element then I have to predict the particulars of how various browsers will style h1 in order to have the p element have the same look as the h1 gets except for differences I specify (probably just the fontsize). Instead, I created a hack (as in <h1>Main Title<br /><span>Subtitle</span></h1> (see https://css-tricks.com/forums/topic/how-to-inherit-from-nonparent-element/)) but haven't tested it much (but see https://css-tricks.com/forums/topic/how-to-inherit-from-nonparent-element/ in case of possible responses) and wonder if, even with enough testing, a more semantic way wouldn't be better.
>
A big problem is loops. Inheritance is loop free.

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.

Received on Friday, 4 March 2016 14:36:26 UTC