Overcoming font issues on IE with DTD (Why is my site's font not being recognized by IE?)

May 23, 2012 - 13:00

It is required of every Drupal developer to keep ahead of common browser compatibility issues. IE is probably the most notorious browser in any drupal developer’s dictionary.

IE is a very peculiar browser in terms of standards compliance. Font issues are very common on IE than elsewhere. Here is a small piece of CSS, that seems to work fine everywhere else other than IE:

#header {

The major mistake in this CSS declaration is that ‘Arial’, the font being used here, is not considered as web-safe font. Arial is more common on modern OS's. Arial is a near-copy of Helvetica, updated slightly. Windows uses Arial in place of Helvetica.

We can overcome this by setting doctype as Transitional (Doctype is used to identify the version of the markup language used to write the current page).

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">

This DTD tells the browser that it contain only HTML elements and attributes. Deprecated fonts, HTML elements and non standard attributes are not rendered.

If we set the DTD as

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 

It will allow deprecated fonts, HTML elements and non standard attributes. This will also fix the above mentioned issue.

Using DTD to overcome such issues is not a recommended method. It would be more ideal that we try to find a better font and write the correct class and style instead of looking for workarounds.

Get Drupal updates straight to your inbox

To prevent automated spam submissions leave this field empty.

Post your comments / questions