CSS Align
Center aligning has no effect if the width property is not set (or set to 100%).
Example
.center {
margin: auto;
width: 60%;
border: 3px solid black;
padding: 10px;
}
Left and Right Align – Using position
One method for aligning elements is to use position: absolute;:
Example
.right {
position: absolute;
width: 300px;
right: 0px;
border: 3px solid green;
padding: 10px;
}
Left and Right Align – Using float
Another method for aligning elements is to use the float property.
Example
.right {
float: left;
width: 300px;
border: 3px solid green;
padding: 10px;
}