W3C home > Mailing lists > Public > www-style@w3.org > March 2016

Re: inheritance from nonancestor

From: Davis, Greg <greg.davis@pearson.com>
Date: Fri, 4 Mar 2016 09:11:02 -0700
Message-ID: <CANnhi74Z_au3rXgVV4N0Nqh7VhQK72Q--4iD+oYXhfreG-LRjw@mail.gmail.com>
To: Nick Levinson <nick_levinson@yahoo.com>
Cc: www-style@w3.org
Hi Nick,
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.

-Greg


On Wed, Mar 2, 2016 at 11:10 PM, Nick Levinson <nick_levinson@yahoo.com>
wrote:

> 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.
>
> --
> Nick
>
>
>
>
Received on Friday, 4 March 2016 16:11:36 UTC

This archive was generated by hypermail 2.4.0 : Friday, 25 March 2022 10:09:01 UTC