Subscriber only lesson.
Sign up to this course to view this lesson.
There are many ways to align and center objects.
When to use
Any time you want to align something, or center something, there are many ways to do it.
We've already looked at text-align for aligning text. There are many ways to align classes and images.
One way to align an image:
Another way to align text is with the position: absolute;
Another way to align text inside a class is to set a line height equal to the height of the class and then use text-align: center
border: 2px solid red;
Hints & tips
- There are many ways to align and center things.
- Position: absolute; allows you to be precise.
- display: block, and margin: auto; is a fun center hack.
Lesson notes are only available for subscribers.