Uppercase

Airplane Graphics

I sometimes receive text documents with headings or emphasis achieved by using uppercase letters. What can we do about this?

Users of word processors often find sneaky ways to emphasise headings by using bold or increased font sizes. During the import into HTML or CMS we can easily remove these un-wanted styles, or convert them to the most appropriate tags (eg. b becomes strongi becomes em). Uppercase letters are different though because they have (usually) been typed in using the capital letters on the keyboard.

furthermore...

The problem is that if we post-process the text and convert uppercase to lowercase, then we lose the places where there is correct need for capital letters. In this article I am going to go through the steps that may help solve the problem.

Uppercase - what is it?

The term 'uppercase' comes from the days when text setters in print shops chose their wood or metal characters from wooden or metal draws. Traditionally the characters for majuscule (capital) letters would be kept in the drawer (or case) above the minuscule letters.

Wikipedia has this to say about the use of capital letters:

In English, capital letters are used as the first letter of a sentence or a proper noun and for initials or acronyms. The first person pronoun I is also capitalised. Lower-case letters are normally used for all other purposes. There are however situations where further capitalisation may be used to give added emphasis, for example in headings and titles or to PICK OUT certain words. There are also a few pairs of words of different meanings whose only difference is capitalization of the first letter. Other languages vary in their use of capitals. For example, in German the first letter of all nouns is capitalised.

It seems that the author of this quote does believe that captial letters can be used for emphas, but I would say that the style of emphasised text should be under the control of the designer (typographer) rather than the author.

What are 'small-caps'?

There is another way to use capital letters to achieve emphasis and this is through small-caps. Wikipedia defines this as:

small caps (short for small capitals) are uppercase (capital) characters that are printed in a smaller size than normal uppercase characters of the same font.

To achieve this style, though the original text needs to have been 'keyed-in' using the upper and lower case letters on the keyboard. If the author types the text using capitals then some conversion needs to take place. To achieve 'small-caps' we need to use CSS.

Example: here is a heading using a h3 tag:

A Very Special Title

here we have the same text (not typed in differently) but using the style declaration style="font-variant: small-caps;"

A Very Special Title

The crucial thing here is that the text is not typed-in capitalised. We want to give the designer the control over the style of headings and not the author. If headings are typed in as capitals then the style cannot be changed in a re-design exercise, unless the text is converted to lowercase.

Conversion Techniques

What if an author does type headings in as capital letters. How can we convert to lowercase?

MS Word has a feature called Change Case under the Format menu. There are several choices including Sentence Case, lowercase andd Title Case. For small amounts of selected text this will work, but you may need to do some hand tweeking for headings. For example:

Say we have a heading typed in thus: THIS IS A VERY SPECIAL HEADING - Using Title Case in MS Word we get:  This Is A Very Special Heading - we need to remove the capital letter for Is and A, to get This is a Very Special Heading. In MS Word this could become very tedious after a while! There is a similar feature in BbEdit for those of you who are using the MAC. With this method we have to do a lot of hand tweeking and process the capitalised headings one at a time. There is no way to process all of the text together, so a logical 2 step process is needed.

Process the Headings Only

It seems a good idea to get the text into (X)HTML first, with all the nasty capitilised headings (well at least you know they are headings!) and then process just those headings. Googling around the web for 'convert to lowercase' we can easily find some useful PHP scripts. Most of them, though do no more than out built-in MS Word or BBedit menus. What we need is a bit more intelligence to leave first letters as capitals except where they are words like a, in, on, the, it, or.

In the PHP manual for 'strtolower' here, BK left a nice little script which seems to do the trick and I have adapted it for my own purposes here:

function RemoveCAPITALS($string)
{
 $lower_exceptions = array(
       "to" => "1", "a" => "1", "the" => "1", "of" => "1", "on" => "1", "in" => "1", "at" => "1", "for" => "1", "an" => "1", "it" => "1");
 $higher_exceptions = array( 
       "I" => "1", "II" => "1", "III" => "1", "IV" => "1", 
       "V" => "1", "VI" => "1", "VII" => "1", "VIII" => "1",
       "XI" => "1", "X" => "1");
 $words = split(" ", $string);
 $newwords = array();
 foreach ($words as $word)
 {
  if (!$higher_exceptions[$word]) $word = strtolower($word);
  if (!$lower_exceptions[$word]) $word[0] = strtoupper($word[0]);
  array_push($newwords, $word);
 }
 return join(" ", $newwords);
}

Other CSS details

As seen above, we can use font-variant with an attribute of small-caps where we want uppercase but with a smaller version for the miniscule characters. It should be noted, though that this effect is usually produced 'on-the fly' by the user agent (browser). The smaller characters are simply scaled down versions of the uppercase character set and this can produce poor quality results for some sizes.

We could also use the CSS rule text-transform: uppercase to force everything to uppercase in a heading or indeed text-transform: lowercase to do the opposite. The important point here is that the text must be entered into the content of the web page as normal upper and lowercase, as per the rules of grammar. The normal rules of the use of capital letters is as follows:

  • First letter of a sentence
  • Capital first letter of proper name of person and place
  • Title or heading - but with no capital letter for small commonly occuring words like for, it, on, in etc.
  • The first person pronoun 'I' must always be uppercase

Wiki page

Posted on 16 Jul around 10am

Tags: