Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

HTML HTML Tables Structuring Tables The Table Foot Element

How to use HTML table's colspan and scope attributes in CSS file?

I was wondering can we use HTML table's attributes such as colspan and scope in CSS file?

I have tried to use colspan but it does not get spanned across three columns.

It seems we can't scope and colspan attributes in CSS file. Anyone here know why?

Thanks in advance

2 Answers

Maciej Czuchnowski
Maciej Czuchnowski
36,440 Points

Colspan is structural, so it shouldn't be manipulated by CSS, which is used for style. I can imagine using colspan and scope in a lot of ways with jQuery though.

Lorenzo Pieri
Lorenzo Pieri
19,772 Points

Would you mind tellin' me those few ideas of yours about the jQuery usage?

Maciej Czuchnowski
Maciej Czuchnowski
36,440 Points

You could target specific tables or rows or cells depending on whether they have specific colspans or scopes. Use these attributes in IF statements. What if your table gets bigger and you add columns dynamically? Then you can increase colspans for footers if that happens. Whenever you want to manipulate structure, these two could come in handy.

Jonas Guedes
Jonas Guedes
8,751 Points

Good point Maciej. Use jQuery with Colspan