Learn

No matter how much styling is applied to text (typeface, size, weight, etc.), the text always appears on the left side of the container in which it resides.

To align text we can use the text-align property. The text-align property will align text to the element that holds it, otherwise known as its parent.

h1 { text-align: right; }

The text-align property can be set to one of the following commonly used values:

  • left — aligns text to the left side of its parent element, which in this case is the browser.
  • center — centers text inside of its parent element.
  • right — aligns text to the right side of its parent element.
  • justify— spaces out text in order to align with the right and left side of the parent element.

Instructions

1.

In style.css, set the text-align property of the main heading (h1) so that it appears in the center.

Take this course for free

Mini Info Outline Icon
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.

Or sign up using:

Already have an account?