CSS: der id-Selektor

 

Mit dem ID-Selektor kann ein Element angesprochen werden, dem eine ID zugeordnet wurde. In HTML- und XHTML-Dokumenten handelt es sich dabei um das id-Attribut. Ein ID-Selektor wird gebildet, indem das Gatterzeichen „#“ vor den ID-Namen gestellt wird.

<!doctype html>
<html lang="de">
<head>
<title>Der id-Selektor</title>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<style type="text/css">
h2 { font-size:20pt; color:blue; }
#rot { color:red }
#kursiv { font-style:italic }
</style>
</head>
<body>
<h2>Blaue &Uuml;berschrift.</h2>
<h2 id="kursiv">Kursive, blaue &Uuml;berschrift.</h2>
<h2 id="rot">Blaue &Uuml;berschrift???</h2>
</body>
</html>
4