Why Can't I Text-align Property To A Hyperlink? - Codecademy

Skip to ContentProfile image of anonymousSubmitted by anonymousover 11 yearsWhy can't I text-align property to a hyperlink?

In this exercise, the link is inside the div, but my text is only centered if I use the text-align property in the div. If I try using it directly on ‘a’ selector, it won’t align my text.

Check screenshot for situation #1, where text-align is in the div: https://www.diigo.com/item/image/4qlwr/gx0p

Situation #2, where text-align is in ‘a’, and text is not centered: https://www.diigo.com/item/image/4qlwr/brvo

Answer 534b9221548c3589f900215a

1 vote

Permalink

because if you assign the text-align center property to the div, it will align everything inside the div. but if you assign the text-align center to the link, the computer doesn’t know to centralize it. the computer can’t tell where to what element it should centralize.

text-align propertys should always be assigned to div elements, block elements so that the computer knows: the text in this box needs to be centralized. if you assign it to the link, it doesn’t know to which block it should be centralized.

Profile image of stetim94Submitted by stetim94over 11 years

Popular free courses

  • Free course

    Learn SQL

    In this SQL course, you'll learn how to manage large datasets and analyze real data using the standard data management language.
    • Checker DenseBeginner Friendly.4 Lessons
  • Free course

    Learn JavaScript

    Learn how to use JavaScript — a powerful and flexible programming language for adding website interactivity.
    • Checker DenseBeginner Friendly.11 Lessons
  • Free course

    Learn HTML

    Start at the beginning by learning HTML basics — an important foundation for building and editing web pages.
    • Checker DenseBeginner Friendly.6 Lessons
Explore full catalog

Tag » A Link Center Css