O'Reilly logo

Eric Meyer on CSS: Mastering the Language of Web Design by Eric A. Meyer

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Styling the Document

The first thing we’ll do is change the horizontal alignment of a couple of elements—the contact information (right-aligned) and the footer (centered), like this:

<style type="text/css">
body {background: white; color: black;}
div#contact-info {text-align: right;}
div#footer {text-align: center;}
</style>

We have included a default body rule so that we know where we’re starting: with black text on a white background. This is the most common browser default, so it’s where we’re going to start. By explicitly declaring these values, we make sure that any CSS-capable browser is going to start from the same point we did when we wrote our styles.

Alignment Myths

The property text-align can be used to center the content of block-level ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required