クラスを使用して、いくつかの異なるスタイルを定義する必要があります。例:
// global table styles - will be applied to all tables
table td
{
background-color: green;
}
// styles for tables with class "style1"
table.style1 td
{
border: solid 1px red;
}
table.style1 th
{
...
}
// styles for tables with class "style2"
table.style2 td
{
border: solid 1px blue;
background-color: white;
}
次に、そのスタイルを適用するテーブルにクラス属性を設定します。
<table class="style1"><tr><td> red border, green background </td></tr></table>
<table class="style2"><tr><td> blue border, white background </td></tr></table>
<table><tr><td> default border, green background </table>
ここで、style1は最初のテーブルのTDに適用され、style2は2番目のテーブルのTDに適用されます。
グローバルスタイル(クラス名なし)は、一致するすべての要素(TDなど)に適用されますが、これらのスタイルは特定のスタイルでオーバーライドできます(background-colorで示されているように、グローバルに緑色に設定されていますが、style2ではオーバーライドされます)。 。
ところで:CSSに関するチュートリアルについては、http://w3schools.com/css/をご覧ください。