Forum How do I...?

Implementing the start and value attributes for ol and li

Webbie
After digging around a bit, i'm thinking that theoretically it should be possible to implement the start and value attributes of ol and li respectively using CSS3.

Particularly of note is this piece on attr (not sure as to whether the spec for attr() has changed since this was written):
http://www.w3.org/TR/2005/WD-css3-values-20050726/#attribute

ol[start]
{
	counter-reset:	list-item attr(start, integer, 0);
}
ol>li[value]
{
	counter-reset:	list-item attr(value, integer, 0);
}


I tried this in Prince, and it generates no CSS parsing errors, but also doesn't work. I know the selectors are fine, as if I throw in some borders they pop up all over the place in my document.

I've allready searched the forum, and it doesn't look as though anyone has suggested this yet. Any ideas or comments?

Edited by Webbie

mikeday
Did you try this with the latest alpha version of Prince 6.0, which has extended support for the attr() function?
Webbie
That's worked nicely with a small revision:

div.print ol[start]
{
	counter-reset:	list-item attr(start, integer, 0);
}
	div.print ol[start]>li:first-child
	{
		counter-increment:	none;
	}
div.print ol>li[value]
{
	counter-reset:		list-item attr(value, integer, 0);
	counter-increment:	none;
}


Now I need to figure out why my cross references have stopped working in 6.

Edit: On a completely unrelated note, I would like to extend congratulations to myself on stealing the thousandth post from more entrenched forum users.
mikeday
Congratulations on making the 1000th post on this forum! And congratulations to all the authors of the 999 posts that preceded it! :D

As to cross-references, there is a bug in the alpha version affecting fragment identifiers which is making internal links and cross-references not work. This will be fixed in the next alpha release; sorry for the inconvenience.
Webbie
Coming back to this now that 6.0 is out, this now works - except that a value of 'none' no longer seems to work in the case that re-numbering is specified in the value attribute of a list item.

Using 'list-item 0' in the same position works just fine.

div.print ol[start]
{
	counter-reset:	list-item attr(start, integer, 0);
}
	div.print ol[start]>li:first-child
	{
		counter-increment:	none;
	}
div.print ol>li[value]
{
	/*
		I have no idea why "none" doesn't seem to work here.
	*/
	counter-increment:	list-item 0;
	counter-reset:		list-item attr(value, integer, 0);
}
mikeday
The "none" keyword isn't inhibiting the increment of the list-item counter, which now gets incremented automatically at each list item unless explicitly overridden, which is more consistent with the CSS specification. I don't think it's possible for "none" to override the automatic increment, as the default value for counter-increment is "none" and that would prevent the list-item counter from ever incrementing. However, the specification is silent on this matter.