Create a Drop Cap Using CSS
Page 1 of 2
Written by
Gregory Scot Collins
Tuesday, 29 August 2006, 5:31 PM
This article has been tested to work with the following products and versions. No guarantee of compatibility, with or without modification, is offered for products or versions other than those listed.
- Internet Explorer 7.0 and 6.0 (Microsoft)
- FireFox 2.0 and 1.5 (Mozilla)
- Opera 9.0 (Opera Software)
- CSS 2.0 and 1.0 (W3C)
- HTML 4.01 (W3C)
IN THIS ARTICLE:
Drop caps, popular in books, magazines and elsewhere, are easy to create in HTML using style sheets. With the right design and content they make a pleasant impression to the users viewing your pages. Let's look at some simple HTML that creates a drop cap using CSS. We will examine how to accomplish this with default line-height as well as approximately double line-height.
Create a drop cap in a paragraph with default line-height
Our first example uses default line-height and the Copperplate font. If this font is not installed on your operating system you may substitute it with another font of your choice. When you use a different font, you might need to adjust the font-size and line-height properties in the dropCap class selector to achieve accurate positioning of the initial. Copy the contents of Listing 1 into a text editor, and then save the file as DropCap-Default.html.
The key to the drop cap is in the style sheet. By setting the float property to left, the span containing the drop cap initial stays to the left and pushes lines of the paragraph to the right. The font-size property specifies how big the initial appears and the line-height property is useful to control the number of paragraph lines that are pushed to the right.
Try it
Launch the HTML file you just created in your favorite browser to see the results. The Internet Explorer, FireFox and Opera browsers render the HTML in Listing 1 as shown in Screenshot 1:

Stumble It!
Digg It!
del.icio.us




