Edit online

Aligning Blocks Horizontally

If you want to align just the text paragraphs from the block, you might find the text-align property useful.

To align a block, it must have a specified width (absolute or as a percentage).

Align Center

This can be done by setting both the margin-left and margin-right properties to auto:

div {
  width: 200pt;
  margin-left: auto;
  margin-right: auto;
}

Align Left

This can be done by setting the margin-left to 0 and margin-right properties to auto:

div {
  width: 200pt;
  margin-left: 0;
  margin-right: auto;
}

Align Right

This can be done by setting the margin-left to auto and the margin-right properties to 0:

div {
  width: 200pt;
  margin-left: auto;
  margin-right: 0;
}