XML technologies / CSS / CSS Cookbook / Typography for the web / Bordered pull quotes

(Excerpt from “CSS Kochbuch” by Christopher Schmitt)

Problem

You want to give a pull quote a top and bottom border, as shown in the following figure.

Bordered pull quote

Figure: A bordered pull quote.

To define left and right borders instead of top and bottom borders, use the properties border-left and border-right:

border-left: 1em solid #999;
border-right: 1em solid #999;

Solution

Use the element blockquote to mark up the pull quote’s content:

<blockquote>
  <p>&laquo;Ma quande lingues coalesce, li grammatica del.&raquo;</p>
</blockquote>

Then style the text and borders using CSS rules:

blockquote {
 float: left;
 width: 200px;
 margin: 0 0.7em 0 0;
 padding: 0.7em;
 color: #666;
 background-color: black;
 font-family: Georgia, Times, "Times New Roman", serif;
 font-size: 1.5em;
 font-style: italic;
 border-top: 1em solid #999;
 border-bottom: 1em solid #999;
}
blockquote p {
 margin: 0;
 padding: 0;
 text-align: left;
 line-height: 1.3em;
}

Discussion

The properties float and width let you specify whether and how the main content flows around the pull quote:

float: left;
width: 200px;

Changing the pull quote’s foreground and background colors sets it apart from the surrounding text:

color: #666;
background-color: black;

Match the colors of the properties border-top and border-bottom to the text inside the pull quote:

border-top: 1em solid #999;
border-bottom: 1em solid #999;

Note that Internet Explorer up to version 5.5 renders the result slightly differently from CSS2-compliant browsers because of its box model bug. Details and a workaround are provided in the recipe Special values for Internet Explorer 5.x for Windows.

See also

  

 

 

 

back to top