Text-align:center Style Not Working In Table Header - Codecademy

Skip to ContentProfile image of bjoleniaczSubmitted by bjoleniaczover 10 yearstext-align:center style not working in table header

Hi, I am trying to get the title of the table into the center of the table. Unfortunately, neither the CSS editor nor the style attribute in thead seems to be working. Despite my best attempts, the title is always aligned to the left. <thead colspan="3" style="text-align:center;"> <th>My photo page</th> </thead>

in CSS: th { text-align:center; }

Why isn’t this working?

Thanks.

Answer 5530b3b786f5527bf7000564

1 vote

Permalink

yes, the title will stay to the left, but why? because you added the colspan to <thead>. from Mozilla developers page:

The HTML Table Head Element (<thead>) defines a set of rows defining the head of the columns of the table.

You aded the colspan to the row, where you should add it to the cell (<th>), because you want to cell to span across multiply cells in the row, the row is already at full-width.

so, you should have this:

<thead><th colspan="3">My photo page</th></thead>

and then define the text-align center in css.

Profile image of stetim94Submitted by stetim94over 10 years

2 comments

Profile image of BishdarSubmitted by Bishdarover 10 years

Thank you. this helped.

Profile image of stetim94Submitted by stetim94over 10 years

you’re welcome

Answer 5532a010e39efe008b0003c8

0 votes

Permalink

Thank you! Worked like a charm.

Profile image of bjoleniaczSubmitted by bjoleniaczover 10 years

1 comments

Profile image of stetim94Submitted by stetim94over 10 years

makes sense to put the colspan on right?

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

Từ khóa » Html Column Header Center Align