Re: [Fwd: Re: [whatwg] simple numbers]

David Woolley skrev:
>> CSS:
>> td:after {
>>     content: " USD";
>> }
> 
> Support for this is far from universal.

You've misunderstood my question. It's not what is being supported 
today, but how UAs are *supposed* to support it. I.e. how would an UA, 
that is acting according to the spec, render generated content in table 
cells.

> More importantly, the currency appears to be essential for the content, 
> whereas anything inserted by style sheets doesn't really exist in the 
> document.  I.E. you seem to be confusing content an styling.

I see your point. However, separating actual numbers from the unit makes 
a lot of sense as well.

A. It provides for easier scriptability.

B. It is the common convention already in use in spreadsheet software.

C. It will make the (X)HTML markup considerably smaller, especially if 
we can attach units to cols or colgroups. (That might not be possible, 
though, because of inheritance rules.[1])

The following, modified example from Web Forms 2.0[2] also shows how it 
would be easier to set units with CSS generated content:

<form>
  <p>
   <label>Quantity
     <input name="a" type="number" step="any" value="0">
   </label>
   <label>Price
     <input name="b" type="number" step="any" value="0">
   </label>
   <output name="result"
           onforminput="value = a.value * b.value">0</output>
  </p>
</form>

I can imagine many scenarios where it would be beneficial to have 
currency units on the output element, as in:

output[name=result]:after {
     content: " USD";
}

However, those characters should probably not be submitted to the server.

Another way to set units might be through an (X)HTML attribute. This 
discussion was started on the WHAT-WG list, as I thought we might even 
need a special number element. That would enable browsers to apply 
special parsing rules for numbers and also give authors a fallback. I.e. 
one could provide a formatted number, with units, that would be 
presented in legacy browsers in the most easily readable format.


Lars Gunther

1. http://ln.hixie.ch/?start=1070385285&count=1
2. http://www.whatwg.org/specs/web-forms/current-work/#the-output

Received on Sunday, 13 January 2008 19:27:48 UTC