Skip to content
View in the app

A better way to browse. Learn more.

MSFN

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Tables in CSS

Featured Replies

I'm wondering if there's any way to change the style of all of a table's cells using CSS. When I use class= on the whole table, only the table itself gets those properties - for example, the border shows up on the outside of the table only, and padding only affects the outermost border, not each individual cell. It is also of course possible to apply a style to all <td> elements, but I want to be able to use classes to have different styles of tables, but I don't want to have <td class="table1"> everywhere. So the question is, can I somehow apply a class to the table and have all cells in the table follow a certain style based on that? Maybe there's some sort of pseudo-class that I'm missing. Anyway, if someone can help, I'd appreciate it. Thanks. ;)

would this do the trick?

table.special tr.special td.special { color:#222222; background:#ffffff; text-align:center; font-Family:sans-serif; }

  • Author

Well, to further simplify that, you could just do

.special {whatever}

But the problem is, then I'd have to add class="special" to every single element - td, th, etc.

Do the reverse in this case as it will tailor to your needs:

.special {}
.special tr {}
.special td {}

If you wish to combine it all into a single line with all matching attributes...

.special, .special tr, .special td {}

With this you'll need but a single class= in your table tag and that is all.

Some much older browsers (NetScape Navigator 4.x for example) however will not like this and will not render the <td>'s through this css unless you treat the tr's indivually in this way. Which would involve tagging the <tr>'s with a class if you wish to render the <td>'s through CSS using '.special TD'.

Additionally, if you are making ALL tables/cells/rows the same colour and want to make them all conform to your CSS, you can do a quick and diry way for it without any classing.

TABLE, TR, TD {}

or

BODY TR, BODY TD {}

Edited by Chozo4

  • Author

OK, I'll try that. That looks like pretty much exactly what I was looking for. I hope it works!

Thanks... I'll let you all know how it works. :hello:

UPDATE:

It worked!! :thumbup Thanks - you've just saved me a lot of work and frustration. :)

Oh, and it doesn't matter for the older browsers - according to the site logs, most of our users are on IE 6 or 7, Firefox 1 or 2, Safari or Opera. All of these browsers seem to render it fine, and for any browsers with issues, it'll still show up, just not quite perfectly.

Edited by Idontwantspam

  • 1 month later...

bgcolor is just background-color

there is no attribute for colspan

Edited by ripken204

Create an account or sign in to comment

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.