[thelist] Another CSS question

Sean XariusX Maddison xariusx at dark-horizon.org
Sun Jan 5 17:40:01 CST 2003

On Sun, 5 Jan 2003 22:12:03 -0000, Donald Noble <donald at drnoble.co.uk>

> Hi evolters,
> just a pondering of mine, when writing css is it better to specify the
> type
> of element it is to be applied to, or just leave the element out...
> 1) div#alpha{}  or  2) #alpha{}

1 is better practice than 2. Especially with classes, not id's. But if file
size is a MASSIVE issue, then go for 2. 1 is preferred.

> the other thing is nested elements, is it best to put...
> 3) table tr td p{}  or  4) table p{}  or  5) td p{}

3. is used for paragraphs that ONLY occur un a <td> under a <tr> inside a

4. is for a <p> ANYWHERE below a <table>

5. is for a <p> inside ANY <td>

Tables are a bad example for this, as you should only ever have a <td>
inside a <tr> inside a <table> a better example would be:

a) h1 b i em {}
The style is applied SPECIFICALLY to <em>'s occuring inside an <i> inside a
<b> inside a <h1>

b) h1 em {}
the style is applied at ALL <em>'s inside <h1>'s

c) i em {}
the style is applied to ALL <em>'s inside <i>'s - regardless of a <h1>
being present

Hope all that made sense...

>>> Sean "XariusX" Maddison
... http://dark-horizon.org/
... xariusx at dark-horizon.org
... Certified virus free by, err, me!

More information about the thelist mailing list