What's the proper format?

Also does anyone know where i can find a good CSS online reference besides W3Schools?

Current Code.

.className td {border: 1px solid #CCC;}
.className th {border: 1px solid #CCC;}

i want to save some characters... would this be valid?

.className td th {border: 1px solid #CCC;}

or

.className td, th {border: 1px solid #CCC;}

or

.className td, .className th {border: 1px solid #CCC;}

Recommended Answers

All 6 Replies

nevermind

This is valid in CSS.

.className td, .className th {border: 1px solid #CCC;}

Yes, I use that latter version as well.

I use the
.className td, th method myself.

Both .className td, th {border: 1px solid #CCC;} and .className td, .className th {border: 1px solid #CCC;} are valid. They simply tell the browser different things.

The first states that the styles should be applied to any td element within an element with a class of className , and any th element within the document. The second states that the styles should be applied to any td element within an element with a class of className , and any th element within an element with a class of className .

If that doesn't make sense I can post an example.


Regards, Arkinder

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.