Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > HTML > Sentence case

Reply
Thread Tools

Sentence case

 
 
BernieH
Guest
Posts: n/a
 
      10-06-2004
I need to display some incoming all-caps text in sentence case (first
letter of each word capitalised). I'm practising on the following code
snippet, but it just won't work. Any idea why?

TIA

BernieH

<html>
<head>
</head>
<body>
<span style="text-transform:lowercase; text-transform:capitalize;">
THIS IS UPPERCASE
</span>
</body>
</html>


 
Reply With Quote
 
 
 
 
brucie
Guest
Posts: n/a
 
      10-06-2004
In alt.html BernieH said:

> I need to display some incoming all-caps text in sentence case (first
> letter of each word capitalised).


the only practical way to do it is use the string functions of your
favorite server side language.

> 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 above only works if the text is initially lowercase. also some
readers may ignore the css and spell out all caps words which would be
annoying.

--
l i t t l e v o i c e s m a k e m e
 
Reply With Quote
 
 
 
 
Mitja
Guest
Posts: n/a
 
      10-06-2004
BernieH wrote:
> I need to display some incoming all-caps text in sentence


> <span style="text-transform:lowercase;
> text-transform:capitalize;"> THIS IS UPPERCASE
> </span>


text-transofrm is a _property_, so it can only have one value, they don't build up. What you end up with, therefore, is
text-transform:capitalize, which completely overrides your other text-transform rule before it.
And yes, capitalization only works for lowercase strings, unfortunately.



 
Reply With Quote
 
Jukka K. Korpela
Guest
Posts: n/a
 
      10-06-2004
brucie <****@usenetshit.info> wrote:

>> I need to display some incoming all-caps text in sentence case
>> (first letter of each word capitalised).

>
> the only practical way to do it is use the string functions of your
> favorite server side language.


Or by something more elaborated. I'm afraid many string functions have no
idea of how many letters there really are. They may well fail to process
properly other bicameral scripts than the Latin script, and they might
even fail for all other letters but "a" through "z" without diacritics.

Of course, naive authors or programmers may assume that everyone uses
English and doesn't even write foreign names correctly.

--
Yucca, http://www.cs.tut.fi/~jkorpela/
Pages about Web authoring: http://www.cs.tut.fi/~jkorpela/www.html


 
Reply With Quote
 
Steve Pugh
Guest
Posts: n/a
 
      10-06-2004
On Wed, 6 Oct 2004 16:42:44 +1000, "BernieH"
<(E-Mail Removed)> wrote:

> 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

 
Reply With Quote
 
Mark Parnell
Guest
Posts: n/a
 
      10-07-2004
On Wed, 06 Oct 2004 18:34:45 +0100, Steve Pugh <(E-Mail Removed)> declared
in alt.html:

> 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>


For sentence case (not title case, as the OP is talking about), you
could use

span {text-transform:lowercase;}
span:first-letter {text-transform:capitalize;}

<span>THIS IS UPPERCASE</span>

--
Mark Parnell
http://www.clarkecomputers.com.au
"Never drink rum&coke whilst reading usenet" - rf 2004
 
Reply With Quote
 
Steve Pugh
Guest
Posts: n/a
 
      10-07-2004
Mark Parnell <(E-Mail Removed)> wrote:
>On Wed, 06 Oct 2004 18:34:45 +0100, Steve Pugh <(E-Mail Removed)> declared
>in alt.html:
>
>> 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>

>
>For sentence case (not title case, as the OP is talking about), you
>could use
>
>span {text-transform:lowercase;}
>span:first-letter {text-transform:capitalize;}
>
><span>THIS IS UPPERCASE</span>


True under CSS2.1 but under CSS 2 the :first-letter only applies to
the first letter of block level elements. Need to test to see what
browser support is like.

Steve

 
Reply With Quote
 
Mark Parnell
Guest
Posts: n/a
 
      10-07-2004
On Thu, 07 Oct 2004 07:26:14 +0100, Steve Pugh <(E-Mail Removed)> declared
in alt.html:

> True under CSS2.1 but under CSS 2 the :first-letter only applies to
> the first letter of block level elements. Need to test to see what
> browser support is like.


Didn't realise that - thanks. Would be better as a paragraph in most
cases, anyway - I was just copying your example.

--
Mark Parnell
http://www.clarkecomputers.com.au
"Never drink rum&coke whilst reading usenet" - rf 2004
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
reverse the order of the words in a sentence Matt Java 11 08-16-2010 09:05 AM
Changing case in a sentence to Capitalize Case. jackson.rayne@gmail.com Javascript 8 09-23-2008 12:04 PM
Simple problem, understanding the case sentence Geo VHDL 6 02-12-2006 04:07 AM
Simple problem, understanding the case sentence Geo VHDL 0 02-08-2006 06:39 AM
process sentence in synthesis Jluis VHDL 3 05-05-2004 10:07 AM



Advertisments