Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

HTML HTML Tables Headers and Footers

Frank Horbelt
Frank Horbelt
1,287 Points

Is it correct to use alignment attributes in the table? Wouldn't it be more correct to use css for this?

I'm just curious.

PS does valign work in css?

I guess I'd like to know about this in regard to cell padding, etc too.

Randolph Judy
Randolph Judy
Courses Plus Student 28,198 Points

It is better to use css for any type of of table formatting. Take advantage of the thead, tbody and tfoot html tags. They make applying css formatting to different sections of the table. easier and in many cases more compact. Here is a simple line of code that you might like for formatting alternate rows of data with a different color.

tbody tr:nth-child(odd){ background-color: skyblue; }

1 Answer

It is considered best practice to always use CSS to achieve your desired look. Especially when dealing with tables. Also, in HTML 5 the alignment property is not supported, so to avoid browser inconsistencies I would use CSS to style my elements.

Also, to vertically align text or elements using css you would use the vertical-align property.