Dreamweaver I | Supplement


 

 

 

 

 

 

 

 

Auto margins calculate the total amount of margin surrounding an element, then split it in half, putting half on the right, half on the left.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

It isn't necessary to define a width for images. However, you need to tell the browser that the image is a block element. Then you can center it as a block.

 

 

Centering with CSS

Whether you need to center a div, a table, an image, or a paragraph, CSS can do the job.

Centering a Div

There are two steps to center a div:

1. Create a class style. In the Box category, define a width for the div. Set the left and right margins to "auto."

2. Apply the class style to the div.

Centering a Tabe

The exact same process can be used to center a table.

1. Create a class style. Define the table's width, and set the left and right margins to "auto".

2. Apply the class style to the table.

Centering an Image

Images are also centered using "auto" margins:

1. Create a new class style. In the Box category, set the left and right margins to "auto".

In the Block category, set display to "block".

2. Apply the class style to the image.

Centering Text

Text can be centered using the text-align:center property (Block category).