Sentence case

Discussion in 'HTML' started by BernieH, Oct 6, 2004.

  1. BernieH

    BernieH Guest

    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>
     
    BernieH, Oct 6, 2004
    #1
    1. Advertising

  2. BernieH

    brucie Guest

    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
     
    brucie, Oct 6, 2004
    #2
    1. Advertising

  3. BernieH

    Mitja Guest

    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.
     
    Mitja, Oct 6, 2004
    #3
  4. brucie <> 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
     
    Jukka K. Korpela, Oct 6, 2004
    #4
  5. BernieH

    Steve Pugh Guest

    On Wed, 6 Oct 2004 16:42:44 +1000, "BernieH"
    <> 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
     
    Steve Pugh, Oct 6, 2004
    #5
  6. BernieH

    Mark Parnell Guest

    On Wed, 06 Oct 2004 18:34:45 +0100, Steve Pugh <> 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
     
    Mark Parnell, Oct 7, 2004
    #6
  7. BernieH

    Steve Pugh Guest

    Mark Parnell <> wrote:
    >On Wed, 06 Oct 2004 18:34:45 +0100, Steve Pugh <> 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
     
    Steve Pugh, Oct 7, 2004
    #7
  8. BernieH

    Mark Parnell Guest

    On Thu, 07 Oct 2004 07:26:14 +0100, Steve Pugh <> 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
     
    Mark Parnell, Oct 7, 2004
    #8
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Geo
    Replies:
    0
    Views:
    485
  2. Geo
    Replies:
    6
    Views:
    538
  3. Steve Franks
    Replies:
    2
    Views:
    1,285
    Steve Franks
    Jun 10, 2004
  4. Tee
    Replies:
    3
    Views:
    7,913
    Herfried K. Wagner [MVP]
    Jun 23, 2004
  5. Replies:
    8
    Views:
    396
Loading...

Share This Page