Advanced Typography

Typographic Hierarchy

ThinkingWithType has an excellent description of typographic hierarchy; it is not specific to the web, but rather gives a definition in general terms.

Applying it to the Web

To apply that to the web, we have a few tags at our disposal; namely h1, h2, h3, h4, h5, h6, and p. On this page, the "Advanced Typography" title at the top is an <h1> tag, the "Typographic Hierarchy" is an <h2>, and "Applying to the Web" is an <h3>. This is not rocket science - don't make it any more confusing than it needs to be. The key is to remember how you are using the tags on your site. For example, for this website the first line of nearly every page is the title, which I'm styling with an <h1> tag.

Super and subscripts

The CSS route is to shift the baseline using vertical-align:super; or vertical-align:sub;

Sample line one
Ex: 152 H2O
Sample line three
Sample line four

The problem, however is the line height will increase and you will have an unsightly gap between adjacent lines (more noticable when using tight leading). A better method is relative positioning with a class such as:

.superscript {
	position:relative;
	top:-0.5em;
	font-size:0.8em;
}
.subscript {
	position:relative;
	top:0.4em;
	font-size:0.8em;
}

Sample line one
Ex: 152 H2O
Sample line three

Yes, this will suffer from line spacing issues, too, but only if the font size of your super or subscripted characters is larger than the surrounding text.

Parenthesis and Dashes with Numbers

Paranthesis are designed for use with lower-case letters. See (here) how nicely they are vertically balanced. If they are used with, say a phone number then things look worse.

(555) 123‑6567original

(555) 1236567fixed

Notice that the parenthesis and dash are too low in the first phone number. You can fix it by wrapping the parenthesis and dash in a span and applying the nudgeUp class.

.nudgeUp {
   position:relative;
   top:-.1em;

}

Typographer’s Quotes

Hanging Quotes

Oh my god, this looks, like, way better.” Because the initial quote is hanging outside the left margin.

This was created with: <p><span style="margin-left:-.5em;">&ldquo;</span>Oh my god...

Another way to create hanging punctuation is via the CSS property text-indent. I think either method is equally valid.

Prime vs. Quotes

Straight (prime) quotes should be used for feet and inches. Example:

My boat is 24′ 9″ long.

My boat is 24&prime; 9&Prime; long.

Curly quotes are created by:

Char= Entity  = Keyboard shortcut (Mac only)
 ‘  = &lsquo; = Opt ]
 ’  = &rsquo; = Opt Shift ]
 “  = &ldquo; = Opt [
 ”  = &rdquo; = Opt Shift [

Because you can directly type the quotes marks with the keyboard doesn’t mean you should. Dreamweaver templates have a problem copying those values over; it’s best to use the Entity values in your code instead.

Curly quotes vs. straight quotes

Curly (a.k.a. typographers or book) quotes should be used for the apostrophy and for quoted material.

Your web visitors should never see the single or double keyboard quote marks on your pages. That is reserved for programming languages like JavaScript, PHP, etc. I suppose the one other exception would be ditto marks.

Others

On a web page, always use the Entity or Hex codes instead of typing these special characters. You’ll run into problems when you need to copy/paste or using them in a Dreamweaver template.

Name Ex:   Entity Hex   Keyboard Shortcut for Mac computers Notes
Ellipse &hellip; &#x2026; Opt ; Depending on the font, three periods often looks better.
Em Dash &mdash; &#x2014; Opt Shift - Use to set off parenthetical material that deserves emphasis. My neighbor’s dog—the dumbest animal on the planet—barks all the time.
En Dash &ndash; &#x2013; Opt - Use in place of the word “to”. The play is from 12:00 – 2:30.
Copyright © &copy; &#xA9; Opt g  
Reg. trademark ® &reg; &#xAE;    
Non-breaking space   &nbsp;  

Command Shift Space (this is a DW shortcut)

 
Zero-width space     &#8203;    

Ligatures

Ligatures (such as fi, fj, fl) can automatically be used with the same property as kerning—text-rendering. To turn it on, set the value to "optimizeLegibility". MDN has a full description.

Alternatively, you could try font-variant-ligatures. Honestly, the web just isn’t ready for ligatures; skip for now.

Small Caps

Using the CSS property font-variant, you can set type in small caps. This is typically done as the introduction to a new chapter or when using acrynoms such as fbi, cia, or ibm; or time values like 1:00am.

.smallCap {
	font-variant:small-caps;
}

Unfortunately, it can look poor depending on the font. Yet another instance where print typography (when using high-quality fonts) beats the web...

Kerning

Kerning pairs (the space between two letters) can be achieved automatically through the CSS property text-rendering.

p {text-rendering: optimizeLegibility;} /* use the font's kerning */

Unfortunately, there are some serious bugs. You could manually adjust the kerning by adjusting the margin-right of the first character. For example, the following text has the "To", "Aw", "we", "om", and "me" pairs kerned via:

<p><span style="margin-right:-12px;">T</span>otally <span style="margin-right:-8px;">A</span><span style="margin-right:-4px">w</span>es<span style="margin-right:-5px;">o</span><span style="margin-right:-5px;">m</span>e</p>

Totally Awesome (kerned)

Totally Awesome (not kerned)

If your website has a lot of large text, then a JavaScript library such as Lettering.js and Kern.js could come in handy.

Drop Caps

Safalra has documented a brute-force method to create drop caps. It is specific to a typeface, which limits its use, but I’m not sure there is a better way to do it.