I need to display some incoming all-caps text in sentence case (first
letter of each word capitalised).
That's not sentence case. Sentence case is where only the first letter
of the sentence and the first letter of proper nouns and I are
capitalised. What you're describing is title case where (almost[1])
every first letter is capitalised.
But that's beside the point...
I'm practising on the following code
snippet, but it just won't work. Any idea why?
<span style="text-transform:lowercase; text-transform:capitalize;">
THIS IS UPPERCASE
</span>
The text-transform property can only apply once to each element so in
this case the last declared property is applied, but because the text
is all upper case text-transform:capitalize; has no effect.
The closest you could get in CSS is something like this:
span {text-transform:lowercase;}
span b {font-weight: normal; text-transform:capitalize;}
<span><b>T</b>HIS <b> I</b>S <b>U</b>PPERCASE</span>
Obviously this is clunky and has disadvantages[2].
Better to either persuade whomever is supplying the text to supply it
in the format you want or to use the server side language of your
choice to transform the text before including it in your pages.
[1] Prepositions, conjunctions ands articles of less than five letters
length are not normally capitalised in title case, hence CSS
text-transform: capitalize; is only an approximation of title case.
[2] ISTR speech browsers that would split the word at a tag, so
<b>T</b>HIS would be read as "tee his". Anyone know if this is still
the case in the current generation?
Steve