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 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,441 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,441 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