Ich benutze IDs, und keine Klassen, weil class länger ist als id, und der code 17*17+3*17=340 mal ausgegeben wird. Da lohnt es sich durchaus an jedem Byte/Zeichen zu sparen.
Die den CSS-Code habe ich jetzt überall ausgelagert, wo er mehr als 1x vorkommt ("border:2px solid #".str_pad(dechex($contrast),2,"0",STR_PAD_LEFT)."FFFF; width:6px;" wird genau zweimal ausgegeben, das ist das markierte Farbfeld).
Jetzt funktioniert alles nach meinen Vorstellungen, vielen Dank an alle Tippgeber!!!
css: #x {padding:0px; width:10px; height:10px}
#a {display:block; width: 10px; height:10px; margin:0px; font-size:8px}
<table style="border-collapse:collapse; float:left; margin-left:1em">
<?php
//---------------------- roter Farbbalken -----------------------
for ($rr = 255; $rr >= 0; $rr = $rr-15) {
if (strtoupper(str_pad(dechex($rr),2,"0",STR_PAD_LEFT)) === "$r") {
$contrast = 255-$rr;
echo("<tr>
<td id="x"
style="border:2px solid #".str_pad(dechex($contrast),2,"0",STR_PAD_LEFT)."FFFF;
width:6px;
background-color:#".str_pad(dechex($rr),2,"0",STR_PAD_LEFT)."0000">
<a id="a"
style="width:6px; height:6px; font-size:4px"
href="admin.php?c=$c&r=$r">
</a>
</td>
</tr>\n");
} else {
echo("<tr>
<td id="x"
style="background-color:#".str_pad(dechex($rr),2,"0",STR_PAD_LEFT)."0000">
<a id="a"
href="admin.php?c=$c&r=".strtoupper(str_pad(dechex($rr),2,"0",STR_PAD_LEFT))."">
</a>
</td>
</tr>\n");
}
}
echo("</table>\n");