Seite 1 von 1

Style nur für bestimmten Bereich

Verfasst: 25.04.2006 17:29
von mbe
Ich möchte folgenden Style

Code: Alles auswählen

<style type="text/css">
a:link { text-decoration:none; font-weight:bold; color:#e00000; }
a:visited { text-decoration:none; font-weight:bold; color:#800000; }
a:hover { text-decoration:none; font-weight:bold; background-color:#ff0; }
a:active { text-decoration:none; font-weight:bold; background-color:#cff; }
a:focus { text-decoration:none; font-weight:bold; background-color:#080; }
</style>
Nur für die obere Reihe Links eines HTML-Dokuments verwenden. Wie kann ich das machen, dass nicht alle Links auf der Seite den Style abbekommen?

Verfasst: 25.04.2006 17:36
von Mr Death
Hi!

Du musst dem Selektor (das vor der Klammer) einfach einen Namen zuweisen. Etwa so:
<style type="text/css">
a.name:link { text-decoration:none; font-weight:bold; color:#e00000; }
a.name:visited { text-decoration:none; font-weight:bold; color:#800000; }
a.name:hover { text-decoration:none; font-weight:bold; background-color:#ff0; }
a.name:active { text-decoration:none; font-weight:bold; background-color:#cff; }
a.name:focus { text-decoration:none; font-weight:bold; background-color:#080; }
</style>
In den Link-Tags schreibst du dann den Selektor in das Klassenattribut. So:
<a href="index.htm" class="name">hier klicken</a>
mfg