How To Align Text Center In Table Heading? - Codecademy

Skip to ContentProfile image of dianasaurusxSubmitted by dianasaurusxover 11 yearsHow to Align Text Center in Table Heading?

Creating the clickable photo album. While this was not required, I’m kind of hung up on how to center-align the text in my table heading. The heading spans three columns but the heading text is left-aligned. I’ve tried a few different things to get it centered and looked up instructions online but so far nothing has worked. Anyone know how to do this?

Answer 53ccf1c59c4e9dd981001b9e

0 votes

Permalink

uhm, can you provide me with your code? check here how to post code.

i build a table but the text aligned centered automatic.

Profile image of stetim94Submitted by stetim94over 11 years

Answer 53cf6992548c35f08b0014fa

0 votes

Permalink

did you take a look at my table? which i linked in my first answer.

here is your table improved: http://jsbin.com/niqad/1/edit

i simple converted your answer to what i think is right (i have to be honest, i am not 100% sure if <th></th> should be between <tr></tr> tags. but anyway, number of mistakes: the colspan attribute should be on the <th> tag, not on the <thead> tag. colspan=”3” not colspan:”3”. i removed the <p></p> tags, no need for those.

Profile image of stetim94Submitted by stetim94over 11 years

1 comments

Profile image of dianasaurusxSubmitted by dianasaurusxover 11 years

Ahh, thanks so much! I appreciate it!

Answer 53ce8e778c1ccc6a650002b2

-1 votes

Permalink

I had the same question- it doesn’t prompt you to change it, just suggests you to without any hint how. Here is my code for the section that allowed me to change the header to span all the columns instead of just the left- pretty easy if you know what you’re doing! Hope this helps!

<head> <link type="text/css" rel="stylesheet" href="stylesheet.css" /> <title>My Photo Page</title> </head> <body> <table><thead><th colspan="3">Photo Page</th></thead> <tbody> <tr> <td></td> <td></td> <td></td> </tr> <tr> <td></td> <td></td> <td></td> </tr> <tr> <td></td> <td></td> <td></td> </tr> </tbody> </table> </body> Profile image of micro-jumper-NSAVkSubmitted by micro-jumper-NSAVkover 11 years

2 comments

Profile image of dianasaurusxSubmitted by dianasaurusxover 11 years

Thanks, Rachel! I got the heading to span all three columns, but I just haven’t been able to get the text inside of it aligned center.

Profile image of stetim94Submitted by stetim94over 11 years

Rachels code is great. only the cells now have zero width, so the text is aligned center. change the width of the cell or simple put some text in, and you will see that the text is aligned center.

Answer 53ceceaa631fe91670000345

-4 votes

Permalink

Here’s my code, stetim94. It’s from the table heading class (4/7). I’ve tried it a lot of different ways but so far the text is still left-aligned.

<!DOCTYPE html> <html> <head> <link type="text/css" rel="stylesheet" href="stylesheet.css" /> <title>My Photo Page</title> </head> <body> <table> <thead colspan:"3"> <th><p text-align:"center"> Photos from My Life</p></th> </thead> <tbody> <tr></tr> <td></td> <td></td> <td></td> <tr></tr> <td></td> <td></td> <td></td> <tr></tr> <td></td> <td></td> <td></td> </tbody> </table> </body> </html> Profile image of dianasaurusxSubmitted by dianasaurusxover 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

Từ khóa » Html Colspan Align Center