I have a small DIV with text-align:center. All it’s contents must be centered. In this DIV I have a PHP code that generates a certain number of A HREF links with display:block. I want all these links to stand next to one another (till it’s too wide for the div, then the need to jump to the next line) so I use float:left. However, if only two links (blocks) show up, they are aligned left in my DIV, instead of in the middle. So I want my links to show up next to each other, but I also want to center them inside my DIV. How do I do this?
CODE per request:
<div style="margin-left:200px;width:300px;text-align:center;background-color:">Pagina's:<br clear="left">
<?php
$sql = "SELECT COUNT(bedrijfsnaam) FROM profiles where plaats = '".$plaats2."'";
$rs_result = mysql_query($sql);
$row = mysql_fetch_row($rs_result);
$total_records = $row[0];
$total_pages = ceil($total_records / 1);
for ($i=1; $i<=$total_pages; $i++) {
echo "<a style=\"float:left;display:block;color:white;width:22px;text-align:center;text-decoration:none;font-size:20px;background-color:#483435;margin-left:4px\" href='".$plaatsnaam7.".php?page=".$i."'>".$i."</a> ";
};
?>
</div>
parent div must have
everything inside must have
display: inline; float: none;