[whatwg] [HTML5] Named start values for lists?

2007/11/8, Ian Hickson:
> On Mon, 26 Jun 2006, dolphinling wrote:
> >
> > HTML5 brings back the |start| attribute on ordered lists. This allows a
> > list to semantically start with a number other than one. It seems like
> > the major use case for this is to split lists up, so that a single list
> > is marked by multiple <ol>s.
> >
> > Would it therefore make sense to allow named start values, so that the
> > author doesn't have to go through and re-number everything when a new
> > item is added at the top? And if so, should they be considered
> > semantically one list? And if so, would it make sense for it to also
> > apply to unordered lists, so that they can be split up, too?
>
> I'm not sure we can put non-numeric values in start="", but I agree with
> your basic proposal. I'm not sure it makes sense for us to add it to HTML5
> at this time -- we have a number of semantic things already added to the
> spec and we don't want to get too far ahead of implementations otherwise
> they'll all start doing different parts and it'll take years to get a
> common subset implemented -- but I think it's something we should consider
> for a future version, certainly.

Semantics put aside (start="" is not really semantic, is it? or why
are counters part of CSS?), you can achieve this using a counter() in
CSS:

<style>
ol.mysplitlist1 {
  list-style: none;
}
body {
  counter-reset: mysplitlist1;
}
ol.mysplitlist1 > li:before {
  content: counter(mysplitlist1) ". ";
  counter-increment: mysplitlist1;
}
</style>
<ol class=mysplitlist1>
<li>First item
</ol>
<p>...
<ol class=mysplitlist1>
<li>Second item
</ol>
<p>...

See it in the Live DOM Viewer, tested working in Firefox 2, Opera
9.24, Safari 3.0.3, doesn't work in IE7:
http://software.hixie.ch/utilities/js/live-dom-viewer/?%3C!DOCTYPE%20html%3E%0A%3Cstyle%3E%0Abody%20%7B%0A%20%20counter-reset%3A%20mysplitlist1%3B%0A%7D%0Aol.mysplitlist1%20%7B%0A%20%20list-style%3A%20none%3B%0A%7D%0Aol.mysplitlist1%20%3E%20li%3Abefore%20%7B%0A%20%20content%3A%20counter(mysplitlist1)%20%22.%20%22%3B%0A%20%20counter-increment%3A%20mysplitlist1%3B%0A%7D%0A%3C%2Fstyle%3E%0A%3Col%20class%3Dmysplitlist1%3E%0A%3Cli%3EFirst%20item%0A%3C%2Fol%3E%0A%3Cp%3E...%0A%3Col%20class%3Dmysplitlist1%3E%0A%3Cli%3ESecond%20item%0A%3C%2Fol%3E%0A%3Cp%3E...


IMO, the thing to consider for the HTML.next is to add semantic to
replace "the lists share the same class" with "the lists are part of
the same overall list"; for both UL and OL (and DL and DIALOG).

-- 
Thomas Broyer

Received on Wednesday, 7 November 2007 23:44:57 UTC