How to Align Elements: CSS
Stephanie Redmond and Samantha Totera
Aligning Block Elements
Using Margins
.center
{
margin-left:auto;
margin-right:auto;
width:70%;
background-color:#b0e0e6;
}
Using Position Property
• absolute positioning is used for really
specific positioning.
• Elements aligned with absolute positioning
are able to overlap one another
.right
{
position:absolute;
right:0px;
width:300px;
background-color:#b0e0e6;
}
Using the Float Property
.right
{
float:right;
width:300px;
background-color:#b0e0e6;
}

CSS Alignment

  • 1.
    How to AlignElements: CSS Stephanie Redmond and Samantha Totera
  • 2.
    Aligning Block Elements UsingMargins .center { margin-left:auto; margin-right:auto; width:70%; background-color:#b0e0e6; }
  • 3.
    Using Position Property •absolute positioning is used for really specific positioning. • Elements aligned with absolute positioning are able to overlap one another .right { position:absolute; right:0px; width:300px; background-color:#b0e0e6; }
  • 4.
    Using the FloatProperty .right { float:right; width:300px; background-color:#b0e0e6; }